WordPress.org

Make WordPress Core

Opened 10 months ago

Closed 10 months ago

Last modified 7 months ago

#52461 closed defect (bug) (invalid)

the_excerpt() not respecting <!--more--> tag on single-post pages.

Reported by: bobbybosler Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description (last modified by desrosj)

Hello there, I've never reported a WordPress bug before, so bear with me. I'm been working with a reputable theme developer, Themeco, with an issue I was trying to resolve, and [according to their estimation](https://theme.co/forum/t/layouts-and-post-excerpts-bug/83415/14/), it appears to be either an issue with WordPress core or an issue with the WordPress documentation being inaccurate. In either case, I'l like to report it as succintly as possible and hopefully get it resolved.

According to [your documentation here](https://codex.wordpress.org/Customizing_the_Read_More), I should be able to enter a <!--more--> tag or the corresponding "Read More" block in the block editor and that should limit what the_excerpt() returns to the text before the more tag (instead of the 55 word limit). And, indeed, it does so everywhere except for the single-post page. On the single-post page, it either returns the manual excerpt or it returns the 55 character limit if there is no manual excerpt.

I may not be doing a good job describing this, so please see [this thread](https://theme.co/forum/t/layouts-and-post-excerpts-bug/83415) for a fuller explanation of the issue. This may appear trivial, but I have reasons for wanting this functionality to work for a site I am working on.

Change History (3)

#1 @joyously
10 months ago

  • Resolution set to invalid
  • Status changed from new to closed
  • Version 5.6.1 deleted

You have misinterpreted the documentation.
The the_content() function called from an archive page (one that shows multiple posts) is the only one that handles the More tag, by truncating the content. When on the single post page, the More tag generates the ID attribute for the More link where the More tag is placed.
The the_excerpt() function retrieves the manually entered excerpt and if it is empty, an excerpt is generated from the content by stripping HTML tags and counting words according to the excerpt_length.

#2 @sabernhardt
9 months ago

  • Description modified (diff)

This is not a bug, though #24588 proposed the enhancement of editing the excerpt function to accept snippets created by a "more" tag/block.

#3 @desrosj
7 months ago

  • Description modified (diff)
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.