• Resolved James Adamthwaite

    (@jamesadamthwaite)


    This is from: http://codex.wordpress.org/Function_Reference/do_shortcode

    echo do_shortcode('[iscorrect]'.$text_to_be_wrapped_in_shortcode.'[/iscorrect]');

    So, I’m getting that in my template just fine, and it’s causing the shortcode to work, but I have no idea how to format the ‘.$text_to_be_wrapped_in_shortcode.’ to get that middle text to show up – it’s just blank.

    Here’s my actual code:

    <?php
    if ( in_category( 'boys' )) {
    	echo do_shortcode('[button color=black]'.$text_to_be_wrapped_in_shortcode.'[/button]');
    }
    ?>

    The black button is showing up, but no matter what I put in the middle, it’s just blank.

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • what is the value of your string $text_to_be_wrapped_in_shortcode ?

    does it work if you use a static text; i.e.:

    echo do_shortcode('[button color=black]some text to be wrapped[/button]');

    what is the actual code for the [button] shortcode ?

    http://codex.wordpress.org/Shortcode_API

    please use the pastebin if the code is longer than 10 lines – http://codex.wordpress.org/Forum_Welcome#Posting_Code

    Thread Starter James Adamthwaite

    (@jamesadamthwaite)

    ok it was the $ that messed me up – I didn’t know why format that had to be.

    Just entering in

    <?php
    if ( in_category( 'boys' )) {
    	echo do_shortcode('[button color=black]View More[/button]');
    }
    ?>

    removing the '.$ and .' and replacing that with text did the trick.

    I was thinking i needed to define a variable in a new line and call that variable or something. THANK YOU!

    echo do_shortcode(‘[iscorrect]’.$text_to_be_wrapped_in_shortcode.'[/iscorrect]’

    What if it is more than just text inside the shortcode. I have content that needs to go inside tabs and I need to put [tab][/tab] around h1 tags, img tags and of course text. How does this work?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘echo do_shortcode – text to be wrapped’ is closed to new replies.