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'm sure I'm missing something simple, as I rarely use shortcodes, but I can't seem to get the following shortcode to work.

I want it to be an "enclosing" short tag vs. a "self-closing", but its being treated as the latter.

[bio_image name="my name" title="my title"]
//image media in post content
[/bio_image]

with this functions.php code:

function bio_image_func( $atts, $content = null) {
    extract( shortcode_atts( array(
        'name' => 'employee',
        'title' => 'mastermind',
    ), $atts ) );
    return '<div class="team_photo"><p class="team_title"><span class="name">' . $name . '</span> <span class="title">' . $title . '</span></p>' . $content . '</div>';
}

add_shortcode( 'bio_image ', 'bio_image_func' );   

produces:

<div class="team_photo">
  <p class="team_title">
    <span class="name">my name</span> 
    <span class="title">my title</span>
  </p>
</div>

<img src="my_img_src" ... />

[/bio_image]

As you can see, the closing tag is just being printed out. Any suggestions?

for reference: the shortcode codex page

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Remove the space after the shortcode name.

add_shortcode( 'bio_image ', 'bio_image_func' );

becomes

add_shortcode( 'bio_image', 'bio_image_func' );

I think WordPress is looking for a closing tag for bio_image[space], which doesn't exist.

share|improve this answer
    
haha omg... it figures. Thank You. –  Zach L Jun 21 '12 at 23:01
1  
lol sorry! You were right when you said "I'm sure I'm missing something simple" ;) –  weberwithoneb Jun 21 '12 at 23:08

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.