0

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?

1 Answer 1

0

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

4
  • 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, 2012 at 3:22
  • wait, I realized you have a mistake, I'm updating Jan 25, 2012 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, 2012 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 Jan 25, 2012 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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