Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to assign a title to my column shortcode. Essentially, [column title="nameofcolumn"]content[/columntitle]. But I'm not quite sure what to do after the "=>" or after my div class of title. I've looked for tutorials but I can't find anything specific enough for me to understand.

function column_shortcode( $atts, $content = null ) {
    extract(shortcode_atts(array(
        'title' => 'WHAT DO I ENTER HERE',
    ), $atts));
   return '<div class="third"><div class="title">DO I NEED SOME TEXT HERE?</div><hr/>' . $content . '</div>';
}

add_shortcode('one_third', 'column_shortcode');

EDIT: Also I'd like to set my 1/3 columns under a row div so I can clear: both. How can I accommodate that?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

yeah, you are kind in the right path, just need to know that the 'title' is a variable that will get and past the value, so you have to call it exactly where you wrote "DO I NEED SOME TEXT HERE", so it goes like this:

 function column_shortcode( $atts, $content = null ) {
 extract(shortcode_atts(array(
    'title' => 'WHAT DO I ENTER HERE',
 ), $atts));
 return '<div class="third"><div class="title">'. $title .'</div><hr/></div>';
}

add_shortcode('one_third', 'column_shortcode');

Notice where you have 'WHAT DO I ENTER HERE', is the default value it will take so probably you might want to leave it blank :)

UPDATE***

I didn't notice that call to the content you had in there, you don't need it, let me know if it goes well

share|improve this answer
    
That easy? Wow haha I was trying so much nonsensical crap. I'll check you off once the time limit lets me. Thanks! –  pope Jan 25 '12 at 3:22
    
wait, I realized you have a mistake, I'm updating –  andresmijares25 Jan 25 '12 at 3:23
    
Alright I'll keep checking on the thread. Oh, also, do you know how to assign a row to those columns so I can use "clear: both" css? –  pope Jan 25 '12 at 3:25
    
I just fixed it, regarding to the clear, yes, you can add it wherever you want into the '', however I don't understand exactly what you want to do, you can also grab em into <li> tags, if you paste the html of the code you rae trying to achieve would be easier –  andresmijares25 Jan 25 '12 at 3:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.