0

I have a problem with a plugin I developed that registers a shortcode. The shortcode returns a string with valid HTML but some themes seems to manipulate the HTML returned by the shortcode, and I really can't understand what is the reason.

For example, this is the correct output of my shortcode:

<div class="tile">
<a>
    <img src="0.jpg" />
    <div class="caption">
        <p>Kate</p>
    </div>
</a>
</div>

and this is the output I get with some theme:

<div class="tile">
<a>
    <img src="0.jpg" />
    <div class="caption">
        <p>Kate</p>
    </div>
</a>
</div>
<p></p></a></div>

As you can see there is some extra tag after the closing of the 'caption' DIV.

Maybe these themes apply some kind of HTML validation/sanitization?

  • What's the code you're using to generate the HTML (the function add_shortcode is using)? – Morgan Estes Jan 3 '14 at 18:45
  • "some themes" namely? – Rarst Jan 3 '14 at 18:45
  • Last theme was themeforest.net/item/… I can't post the code I use but is simply something like: $html = ""; $html .= "<div>"; ... $html .= "</div>; return $html; – Darko Romanov Jan 3 '14 at 18:48
  • Does it happen with Twenty Fourteen? Or Twenty Thirteen? – s_ha_dum Jan 3 '14 at 20:16
  • It doesn't happen with the TwentyFourteen nor with Twenty Thirteen, it happens with some other themes, like themeforest.net/item/… – Darko Romanov Jan 4 '14 at 11:27
0

It looks like you are getting caught in some wpautop() replacements. Many people find the defualt WordPress wpautop() filter to be frustrating. So often in highly customized themes, there is a homegrown replacement.

For example, the theme you mentioned has a replacememt for some of the default WordPress filters. You can see a thread about it here... http://kaptinlin.com/support/discussion/1835/disable-automatic-p-tags/p1

The only recommendation I can make is to remove the clean formatting ( indents, newlines, etc. ) and see if that helps. Don't give the filters anything to wrap.

  • Thank you very much! I see the theme author suggests to edit the sources of the theme... I don't like that at all but at least I know what is the problem. – Darko Romanov Jan 4 '14 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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