Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#12536 closed defect (bug) (wontfix)

get_the_content does not properly trim split post (read more link)

Reported by: Ateo Owned by:
Milestone: Priority: high
Severity: minor Version: 2.9.2
Component: Formatting Keywords: has-patch tested
Focuses: Cc:


When you utilize <!--more--> in a post to effectively add a 'read more' link the end to the end of the post linking to the full article (on home page stream), the function fails to trim the chunk to be displayed leaving the trailing new line maker (\n) thus when default filter wpautop is applied, it naturally converts that trailing maker into a br tag, as it should.

This affects formatting/placement of the 'read more' link. I personally want my 'read more' link immediately following my text. This isn't possible without trimming the chunk of text. As such, the 'read more' link is bumped to the next line down. =(

Anyways, the fix is super super easy! I swear.

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

$output = trim($output);

This is from WP version 2.9.2. Not sure in which version this became apparent, if not always.


Attachments (1)

12536.diff (696 bytes) - added by Denis-de-Bernardy 5 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 @Denis-de-Bernardy5 years ago

  • Milestone changed from Unassigned to 3.0

@Denis-de-Bernardy5 years ago

comment:2 @Denis-de-Bernardy5 years ago

  • Keywords has-patch added

please try the attached patch for trunk.

comment:3 @Ateo5 years ago


Sorry for the wrong line number. =)

comment:4 follow-up: @Ateo5 years ago

arg. hah. i *did* provide the correct line..

comment:5 in reply to: ↑ 4 @Denis-de-Bernardy5 years ago

  • Keywords tested added

Replying to Ateo:

arg. hah. i *did* provide the correct line..

I'm sure it is in 2.9.2 :-)

comment:6 @nacin5 years ago

I'm not sure about this.

If you have a more link at the end of your content, like so, then it will be displayed on the same line. <!--more-->

If you have a more link on the next line, like so, then it will be displayed on the next line.

If you have a more link as if it is its own paragraph, then it will be displayed as its own paragraph.

Changing this will cause some people to complain that their more links are no longer displaying as their own paragraph, because that is how they may prefer it. But currently, you can have your way if you include <!--more--> inline.

comment:7 @nacin5 years ago

Of course, the second example should be:

If you have a more link on the next line, like so, then it will be displayed on the next line.

Suggesting wontfix.

comment:8 @nacin5 years ago

  • Milestone 3.0 deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.