1

WP has me pulling my hair out at the moment (past few days trying to solve).

Trying to do some simple shortcodes which wrap around various points of an article. However wpautop() I believe is wreaking havoc. Ive tried various suggestions found around the net including viperbonds ( http://www.viper007bond.com/2009/11/22/wordpress-code-earlier-shortcodes/ ) to control when the shortcodes run but I am still getting various annoyances whether the shortcode runs before or after wpautop. It only formats out the shortcode unblemished with wpautop disabled entirely but the rest of the post is then not formatted.

I have a shortcode [REVIEW_SUMMARY]The conclusion text/paras here... written by editor[/REVIEW_SUMMARY] in simple terms it builds out a specific consistent set of titles and from various custom meta data builds out scoring, imagery etc. Works fine for the most part.

The problem is a scoring tile we have which outputs as part of the final content of this shortcode:

<div class="tile-score"><div><span>9.9</span><small>Out of 10</small></div><b>Our score</b></div>

Full example output (stripped a bit because it be too long) of shortcode with wpautop disabled:

<section><h1>Summary</h1>
<div id="score_review_container" class="clearfix"><a href="#" class="score-review-image"><img src="#" width="99" height="180" alt="#" /></a><div class="score-review-meta"><h2><a href="#">Item Reviewed</a></h2><div class="tile-score"><div><span class="ft-arb">9.9</span><small>Out of 10</small></div><b>Our score</b></div></div></div>Paragraph1...

Paragraph2...

Paragraph3...

Paragraph4...</section>        

It definitely has no line breaks and so forth that WP should format (apart from what you would expect from the paragraph's.

However turning wpautop it on it generates ( ran before wpautop() ):

<div class="tile-score">
<div><span>9.9</span><small>Out of 10</small></div>
<p><b>Our score</b></div>

Full version (stripped a bit) of generated code and ran before wpautop() runs:

<section>
  <h1>Summary</h1>
  <div id="score_review_container" class="clearfix">
    <a href="#" class="score-review-image">
      <img src="#" width="99" height="180" alt="#" />
    </a>
    <div class="score-review-meta">
      <h2><a href="#">Item Reviewed</a></h2>
      <div class="tile-score">
        <div><span class="ft-arb">9.9</span><small>Out of 10</small></div>
        <p><b>Our score</b>
      </div>
    </div>
   </div>
   <p>Paragraph1</p>
   <p>Paragraph2</p>
   <p>Paragraph3</p>
   <p>Paragraph4/p>
  </div>
</section>

PLEASE NOTE: then Para4 end

is actually like that. Its missing the bracket < and the inserted

before Our score.

At no point should there be any line breaks I have not told it to nor should there be an open

tag not to mention it doesn't close it and the rogue broken end p tag.

Full version (stripped) ran AFTER wpautop():

<section>
  <h1>Summary</h1>
  <div id="score_review_container" class="clearfix">
    <a href="#" class="score-review-image">
      <img src="#" width="99" height="180" alt="#" />
    </a>
    <div class="score-review-meta">
      <h2><a href="#">Item Reviewed</a></h2>
      <div class="tile-score">
        <div><span class="ft-arb">9.9</span><small>Out of 10</small></div><b>Our score</b></div></div></div>Para1...</p><p>Para2...</p><p>Para3...</p><p>Para4...</section>

Im absolutely stumped as to what is generating the rubbish. The above is an example ran before wpautop() runs which keeps all paragraphs on the rest of the content within the shortcode in tack.

2
  • That final full version is after wpautop() and it sorted the score tile not breaking but the paragraphs wrapped in the shortcode are missing start and ending <p> tags at the start of paragraph1 and end of paragraph4. Thanks for any help in advance its driven my insane.
    – Jimbo
    Mar 8, 2013 at 14:58
  • I can force it to work using the after wpautop() by wrapping the $content returned by the shortcode (the paragraphs wrapped in [REVIEW_SUMMARY]) in <p> tags like '<p>' . $content . '</p>' but this doesnt seem right to me that it should be necessary to do so and that its a bit hacky.
    – Jimbo
    Mar 8, 2013 at 15:09

1 Answer 1

0

Guess then the way to fix this is to wrap the content in <p> tags as a hack to get around it. Seems the only way as WP wont detect it properly.

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.