Opened 15 years ago
Closed 15 years ago
#10395 closed enhancement (fixed)
wp_trim_excerpt() filterable [...] string
Reported by: | ramiy | Owned by: | |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | 2.8 |
Component: | Template | Keywords: | has-patch |
Focuses: | Cc: |
Attachments (2)
Change History (10)
#3
follow-up:
↓ 5
@
15 years ago
i agree with you, but the filter the_content_more_link works only when using the_content() function. And all other techniques to change the more-tag (http://codex.wordpress.org/Customizing_the_Read_More) don't work when using the_excerpt() function.
#5
in reply to:
↑ 3
@
15 years ago
Why not use php's preg_replace function?
With a little regexp you can find the '[...]' and replace it with what ever you like.
I just added this to my functions.php
eg:
function moreLink($content){ return preg_replace('/(\[...\])/','<small><a href="'.get_permalink().'">More ...</a></small>',$content); } add_filter('the_excerpt', 'moreLink');
#6
@
15 years ago
I just added this to my functions.php eg:
Just note that that doesnt work as you expect. It'll also replace [ABC] with the more link..
Since you're not using a regular expression, you're better off using str_replace:
function moreLink($content){ return str_replace('[...]','<small><a href="'.get_permalink().'">More ...</a></small>',$content); } add_filter('the_excerpt', 'moreLink');
#7
@
15 years ago
This is a very nice solution but it doe's not provide a general solutin to the real problem - The the_content_more_link filter does not work when using the_excerpt() function.
Besides, the solution must be in the wp core whitout using functions.php file.
Adding a new filter to wp_trim_excerpt() function is simpler to use and it workes the same as $excerpt_length filter.
// Changing excerpt length function new_excerpt_length($length) { return 20; } add_filter('excerpt_length', 'new_excerpt_length'); // Changing excerpt more function new_excerpt_more($more) { return '.....'; } add_filter('excerpt_more', 'new_excerpt_more');
bouth filters are in wp_trim_excerpt() function.
I removed some keywords, a list of keyword that are used can be found at: http://codex.wordpress.org/Reporting_Bugs#Trac_Keywords
This is a good idea and I bet there are people that would rather change from the [...] to something else. Plus there is a filter for the_content_more_link, so shouldn't excerpt have one too?