WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 2 months ago

#25349 new enhancement

Can't retrieve calculated excerpt bound by <!--more--> on single page view

Reported by: chriscoyier Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.6.1
Component: Posts, Post Types Keywords: has-patch needs-testing
Focuses: template Cc:

Description

Submitting as Mr. Nacin suggested would be a good idea.

The issue in words I understand is: when you use the_excerpt() on (for instance) a custom page template, it ignores the <!-- more --> comment that you might have carefully placed in your content. I would expect it to honor this, since that is kind of the point of that special comment. the_content() will honor it when used on non-single-pages, but in the case of a custom page template, the_content() will of course spit out the entirely of the content.

Andrew gave me this code which does the trick: https://gist.github.com/nacin/ab97d4b0e57b169d26d5 but is apparently hacky and not for public consumption.

This is my lame visual of where I was running into the issue: http://glui.me/?i=5bcy8yr99pl7xel/2013-09-17_at_4.28_PM_2x.png/

Also apparently I'm not the only one who's had this come up recently: https://twitter.com/ShaneHudson/status/380105193419186176

Attachments (1)

25349.patch (710 bytes) - added by Frank Klein 2 months ago.

Download all attachments as: .zip

Change History (8)

comment:1 chriscoyier7 months ago

Oh also. The docs are pretty clear on this point, so if it changes the docs would need to be updated.

http://codex.wordpress.org/Customizing_the_Read_More
http://codex.wordpress.org/Function_Reference/the_excerpt

comment:2 Otto426 months ago

Are you referring solely to the automatically generated excerpt here, or are you trying to use more in a manual excerpt situation?

Need info, possibly example, to reproduce the problem. Input, expected behavior, actual output.

comment:3 chriscoyier6 months ago

Input and expected output: http://glui.me/?i=jufghv8i893tkux/2013-10-08_at_9.21_AM.png/

Actual output: the_excerpt() ignores my explicitly-chosen excerpt and just displays 55 words instead. the_content() honors it on non-permalink pages, but you can't always use that (e.g. you use a loop on a custom page template, it will just display the entire content, but the desire is to output an excerpt).

comment:4 nacin6 months ago

Basically, the_excerpt() should do internally what my gist above does. It should set $more to 0, then reset it to its original value when done.

These globals is some of the oldest code in core, dating back a decade. Lame, but a quick adjustment at least solves the problem here, until one day in the next few releases when we rewrite a lot of this code (we were close to doing so in 3.6).

comment:5 nacin3 months ago

  • Component changed from General to Template
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

comment:6 nacin3 months ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added

Frank Klein2 months ago

comment:7 Frank Klein2 months ago

  • Keywords has-patch needs-testing added; needs-patch removed
Note: See TracTickets for help on using tickets.