Opened 12 years ago
Closed 10 years ago
#24588 closed enhancement (wontfix)
Excerpt enhancement request
Reported by: | Looimaster | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
I originally posted this on WordPress StackExchange but I think that this should go to trac for consideration as well.
I was wondering what should be used in index.php (post listing page): the_excerpt()
or the_content()
?
- Twenty Thirteen uses
the_content()
but this prints entire content unless<!--more-->
exists and it completely ignores Excerpt field from [Posts > Add New > Excerpt]. - So, I used
the_excerpt()
instead but this doesn't react to<!--more-->
tag at all and it just grabs first 55 words or uses manual Excerpt and doesn't produce "Read more..." link.
What I think is the most expected behavior is this:
- print 55 words
- but react to
<--more-->
- and if manual excerpt is specified, use this instead (most people don't want the beginning of their post to be their excerpt so this is of crucial importance)
- produce optional "Read more..." link
I know what you say here:
- http://codex.wordpress.org/Function_Reference/the_excerpt
- http://codex.wordpress.org/Excerpt
- http://www.rarst.net/script/wordpress-excerpt-teaser/
But what I described above looks like the most intuitive to me for post listing pages. The excerpt should be a single, configurable function that is suitable for both BLOG and ARCHIVES. And the_content()
can stay for SINGLE.
Currently neither the_content()
nor the_excerpt()
works for BLOG and requires filters.
the_content()
would do the job right but I think that most theme users aren't familiar with <--more-->
tag and they rather expect that themes will create proper excerpts for post listing pages rather than displaying full post content (and after all the_content()
ignored manual excerpt so it's a big drawback). Currently this can be achieved only with custom filters.
Change History (5)
#2
@
12 years ago
Most themes that use the excerpt on archive pages add their own "Read more"-link, either trough a filter or explicitly in the template. Why is that a problem?
If "theme users" are not aren't familiar with the <!--more-->
quicktag, then why would they be familiar with using the manual excerpt?
The word count is filterable. Why also as an argument? One way or the other, and we have a filter.
To me this makes perfectly sense, quoted from the codex:
When a post has no manual excerpt and the post template uses the
the_excerpt()
template tag, WordPress generates an excerpt automatically by selecting the first 55 words of the post. When the post template uses thethe_content()
template tag, WordPress will look for the More tag and create a teaser from the content that precedes the More tag.
Through has_excerpt()
you can make a choice for each post. You should even be able to detect if the post author has used the <!--more-->
tag in the content, or not.
So what is it you cannot do with these template tags and the available filters?
I guess that if there is a very common use case, there could be a the_content_or_excerpt()
function, based on some standard criteria, to make life easier for theme developers.
#3
@
12 years ago
Well, I'm leaving it up to you. Like I mentioned I can use filters and this works but I think that plugins such as this http://wordpress.org/plugins/advanced-excerpt/ are created because the original function is lacking everything that this plugin does.
the_content_or_excerpt()
would probably be a good improvement.
Current excerpt function:
Improved excerpt function:
<!--more-->
tag? Note: this can be also responsible for choosing ellipsis and/or "Read more..." text like it does it now inthe_content()
false
for backwards compatibility but the excepted would betrue
(actually, with such configurability you can even merge
the_excerpt()
andthe_content()
)