Make WordPress Core

Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#29623 closed enhancement (wontfix)

Supporting number of characters for excerpts

Reported by: valeriosza's profile valeriosza Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: template Cc:

Description

I tried looking for something here on trac and found and sorry for the English.

The the_excerpt does not have native functions to limit the amount of characters. Something useful when you have to use different amounts of characters on each page.

Example the_excerpt (50, words)

for use on front page

and the_excerpt (100, characters)

for use in category.php

There is something ever talked about it?

Change History (9)

#1 @obenland
10 years ago

Excerpts come with a few filters, that lets you do pretty much anything, if the default output doesn't work for your specific needs. Twenty Eleven actually uses one of them to modify it.

There is excerpt_length and excerpt_more in wp_trim_excerpt()(#), and of course get_the_excerpt and the_excerpt in the excerpt template tags (#).

Since it's so highly customizable through filters, it shouldn't really need additional arguments to achieve that.

#2 @grapplerulrich
9 years ago

@obenland - Twenty Eleven modifies the number of words but not characters which is why this ticket was opened.

#3 @obenland
9 years ago

There are more filters than the one Twenty Eleven uses, that was just an example. 'wp_trim_excerpt' passes the entire excerpt text, as do 'get_the_excerpt' and 'the_excerpt'.

#4 @swissspidy
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing this after no traction for over 2 years. Feel free to reopen when a patch emerges, otherwise filters exist to modify excerpts.

#5 @grapplerulrich
7 years ago

I think there is interest for this. I have had a few themes create their own solution so that they limit the number of character outputted in the excerpt while reviewing themes for the theme review team.

I suppose the ticket is not easy to find as the title is not ideal. Could someone change the title to something like "Supporting number of characters for excerpts" Was able to do it myself.

wp_trim_words() currently supports characters but only if the string 'words' is translated as 'characters'

Last edited 7 years ago by grapplerulrich (previous) (diff)

#6 @grapplerulrich
7 years ago

  • Summary changed from the_excerpt parameters to Supporting number of characters for excerpts

This ticket was mentioned in Slack in #themereview by grapplerulrich. View the logs.


7 years ago

#8 @metallicarosetail
7 years ago

I would like to see this feature available very soon. We could use functions as

 wp_trim_characters('50');

to count character in similar way the excerpt does.

Last edited 7 years ago by metallicarosetail (previous) (diff)

#9 @beysim
7 years ago

This can be really useful for theme authors. Please, consider adding it.

Note: See TracTickets for help on using tickets.