I have following shortcode:

function infobox_shortcode( $atts, $content = null ) {

    extract( shortcode_atts( array(
      'src' => '',
      'title' => '',
      'text' => '',
    ), $atts, 'infobox' ) );

    $return = '<div class="infobox clearfix"><div class="col-md-1 infobox-image"><img src="'.$src.'" alt="'.$title.'"/></div><div class="col-md-8 infobox-content"><h2> ' . $title . '</h2><p>' . $text . '</p></div></div>';

    return $return;

add_shortcode( 'infobox', 'infobox_shortcode' );

This works fine, when the user uses it simple like so:

[infobox src="http://www.google.com" title="Google" text="Some description"]


As soon as the users tries to add e.g. a link with quotes to the shortcode, it - of course - breaks:

[infobox src="http://www.google.com" title="Google" text="Some description - see more: <a href="http://www.google.com">More here</a>"]

Issue is that my user uses the WP Editor to add a link and this makes double quotes. Alsor WordPress seems to delete single quotes for attributes by default and adds double quotes which then again break my shortcode.

Right now I see 2 solutions for this, but both are not quite satisfying.

a) Tell WP not to convert single quotes to double quotes in a href links while saving a post or b) To make the shortcode work with double quotes.

Any other hints or workarounds I can go with this?



  • Since it seems you are writing the shortcode could you not dynamically add the "See More {link}" part within the shortcode? May 12, 2014 at 10:27

1 Answer 1


Either way this seems like a very clunky solution for arbitrary markup in shortcode.

If only one of attributes is more bulky and includes markup I would consider making shortcode enclosing:

[infobox src="http://www.google.com" title="Google"]
    Some description - see more: <a href="http://www.google.com">More here</a>

You might be to the point when you'll need to built custom UI or it will just be too error prone for users.

  • Hi Rarst, think you are right. The way you pointed out seems much better then enclosing everything in the shortcode brackets [] and quotes. I'll try that, thanks!
    – Mike
    May 12, 2014 at 13:35

Your Answer

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

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