Support » Fixing WordPress » wpautop filter breaks ‘read more’ (sort of)

  • The Issue
    When you utilize a <!–more–> tag to break up longers posts, the ‘read more’ link is bumped down and forced to a new line. The default WordPress format is to insert a break tag, forcing the ‘read more’ link to a new line. This is fine in some cases, but not all. Some users want the ‘read more’ link immediately after the “excerpt”.

    The Culprit
    The default filter, “wpautop”, somewhat breaks the ‘read more’ functionality for the_content function when you split a post into two parts so that you can display an “excerpt” of each post (instead of the full post) on your blog’s index page stream. Unfortunately, this cannot be easily addressed with a plugin because default filters are deep inside WorPress code.

    The Solution
    Until WordPress addresses this in a future release, here is the fix. The fix essentially removes the offending filter when the post utilizes the <!–more–> tag.

    File: wp-includes/post-template.php
    Line: 217

    remove_filter('the_content', 'wpautop');

    I hope this can be implemented in a future release.


Viewing 4 replies - 1 through 4 (of 4 total)
  • This essentially allows use to insert our own break tag through our theme. Example:

    the_content('<br />read more...');

    Oh, and it also only works when you put the <!–more–> tag *after* the first paragraph. Otherwise, it mashes all paragraphs into one (up to the more tag.

    I’m try to figure out how I can address this..

    Ok. Crap. Sorry for being totally retarded and not really spending more time.. Anyways, the fix is the almost the same…

    Same file, same line. But this is the correct line of syntax:

    $output = trim($output);

    We essentially just strip off any white space. poof. problem solved. duh…



    How will that work with wordpress 3?
    is there any option to make the “Read More” appear right next to the last word of the excerpt. Like that: Read More

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wpautop filter breaks ‘read more’ (sort of)’ is closed to new replies.