Forums

[resolved] Has wpautop changed? (7 posts)

  1. YorkshireLad
    Member
    Posted 2 years ago #

    Hello,

    I use
    remove_filter('the_excerpt', 'wpautop');
    on a couple of sites, one of which is no longer needed and no longer updated. On that site, the p tags are correctly removed from the excerpt field like this:

    <div class="entry">
    	<p>	<img src="/wp-content/furniture/Watch_button.png" alt="Watch video" class="watch_inline" />
    	My excerpt</p>
    	</div>

    On another site, with the same images and styles, I get this:

    <div class="entry">
    	<p>	<img src="/wp-content/furniture/Watch_button.png" alt="Watch video" class="watch_inline" />
    	<p>My excerpt</p>
    </p>
    	</div>

    I've noticed this on another site with different markup. Did I miss something? Was there a syttax change?

    Gary

  2. YorkshireLad
    Member
    Posted 2 years ago #

    Just to expand on this: have a look at http://www.leedsunitedladies.com/category/news

    Notice how the image is above the text; that's because the excerpt is wrapped by unwanted p tags.

    Now look at http://www.leedsunitedladies.com/category/news/page/8 or http://www.leedsunitedladies.com/category/video on the same site - notice how the image and text are in line with each other.

    The image appearance is governed by a bit of php. If the relevant custom field has the value 'yes', show the image; otherwise, carry on and show just the excerpt.

    I'm at a loss as to what has changed, beyond WordPress and my installed plugins (none of which, that I can see, would ever switch wpautop back on).

    Gary

  3. YorkshireLad
    Member
    Posted 2 years ago #

    Further investigation shows that the errant behaviour is only happening on posts dated later than 18 June 2010.

    I commented out the remove_filter and used the following function:

    `function my_real_excerpt() {
    global $post;
    $bill = $post -> post_excerpt;
    $my_excerpt = substr($bill,3,-5);
    echo $my_excerpt;
    }'

    That works in removing the p tags before and after the excerpt for posts dated later than 18 June, but posts earlier than that don't seem to have any p tags associated with them anymore - so I actually truncate valid characters of my excerpt.

    Coincidentally, WordPress 3.0 came out on 17 June 2010...

    Gary

  4. YorkshireLad
    Member
    Posted 2 years ago #

    And yet more investigation - this time of the database itself - shows that all those posts created since the upgrade to 3.0 have paragraph tags inserted into the post_excerpt field in the database. Posts before that time do not.

    Tsk. Will raise a ticket, when I work out how to... it's not wpautop's fault after all...

    Gary

  5. m_disseny
    Member
    Posted 2 years ago #

    Hey Gary,

    just came across the same problem this morning. I was programming a new template and copied/pasted this function from my notes:

    <?php remove_filter (‘the_content’, ‘wpautop’); ?>

    and it didn't work, I thought it could be a 3.0 bug at first but then I noticed there was a syntax error with the inverted commas. Just changed for this and now works like a charm:

    <?php remove_filter ('the_content', 'wpautop'); ?>

    Maybe too obvious, I guess this is not your issue, but hope this helps.

    Marc

  6. YorkshireLad
    Member
    Posted 2 years ago #

    Hi Marc,

    Not obvious at all, but I had tried that, just to be on the safe side.

    I'm actually now beginning to wonder if it's related to TinyMCE Excerpt, though I can't see how. Basically, anything created or updated since mid-June is affected. Deactivating the plugin doesn't store the additional paragraph tags, so it's now prime suspect...

    Gary

  7. YorkshireLad
    Member
    Posted 2 years ago #

    Just to round this off (and not really 'resolved', but I've fixed the problem for me): not having heard from the TinyMCE Excerpt developer, I added the following to my functions.php file, and called it every time I wanted to call the_excerpt()

    function my_real_excerpt() {
    	global $post;
    	$bill = $post -> post_excerpt;
    	$billA = substr($bill,0,3);
    	if ($billA == '<p>') {
    	$my_excerpt = substr($bill,3,-5);
    	echo $my_excerpt; } else { echo $bill; }
    	}

    In other words: get the_excerpt, look at the first three characters; if it's a p tag, strip it and the closing tag, otherwise return what you find.

    Works for me, your mileage may vary.

    Gary

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags