WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 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:

Description

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

$output = trim($output);

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

Thanks!

Attachments (1)

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

Download all attachments as: .zip

Change History (9)

comment:1 Denis-de-Bernardy4 years ago

  • Milestone changed from Unassigned to 3.0

Denis-de-Bernardy4 years ago

comment:2 Denis-de-Bernardy4 years ago

  • Keywords has-patch added

please try the attached patch for trunk.

comment:3 Ateo4 years ago

Works.

Sorry for the wrong line number. =)

comment:4 follow-up: Ateo4 years ago

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

comment:5 in reply to: ↑ 4 Denis-de-Bernardy4 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 nacin4 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.
<!--more-->

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 nacin4 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.
<!--more-->

Suggesting wontfix.

comment:8 nacin4 years ago

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