WordPress.org

Ready to get started?Download WordPress

Forums

wpautop filter breaks 'read more' (sort of) (5 posts)

  1. Ateo
    Member
    Posted 4 years ago #

    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
    AFTER ADD:

    remove_filter('the_content', 'wpautop');

    I hope this can be implemented in a future release.

    Thanks!

  2. Ateo
    Member
    Posted 4 years ago #

    This essentially allows use to insert our own break tag through our theme. Example:

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

  3. Ateo
    Member
    Posted 4 years ago #

    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..

  4. Ateo
    Member
    Posted 4 years ago #

    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...

  5. helppress
    Member
    Posted 3 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic