Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#11456 closed defect (bug) (fixed)

excerpt_more tweak

Reported by: demetris Owned by:
Milestone: 2.9 Priority: high
Severity: normal Version: 2.9
Component: Formatting Keywords: has-patch
Focuses: Cc:


I believe this should be considered and accepted or rejected before 2.9 final, that is, before people start using the new EXCERPT_MORE filter.

Currently the MORE that is added to the autogenerated excerpt is:


(EXCERPT_MORE is added to the array with array_push(), and then the array is imploded with SPACE as a string.)

However, the filterable EXCERPT_MORE is just:


I think the two should be the same.

Here is a case in which the current behaviour is problematic: I want to replace the default EXCERPT_MORE with a simple ellipsis, expecting to get:

Blah Blah.  This is an excerpt autogenerated by{ELLIPSIS}

Instead, I get:

Blah Blah.  This is an excerpt autogenerated by{SPACE}{ELLIPSIS}

To get this space removed, you have to go and apply filtering to a lower level, which I think defeats the purpose of introducing a user-friendly EXCERPT_MORE filter. (On the other hand, if folks do want a space there, there is no easier thing than starting your custom EXCERPT_MORE with a space.)

I’m attaching a patch — more as a demonstration of what I am after, as I don’t know what is the proper way to make this change to wp_trim_excerpt.

Attachments (1)

t11456-excerpt-more-tweak.diff (1.4 KB) - added by demetris 6 years ago.
excerpt_more tweak, to make the filterable excerpt_more also include the space that WP adds before it.

Download all attachments as: .zip

Change History (7)

@demetris6 years ago

excerpt_more tweak, to make the filterable excerpt_more also include the space that WP adds before it.

comment:1 @automattor6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12414]) Make the excerpt_more filter include the space. Props demetris. fixes #11456

comment:2 @hakre6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Why is there the concatnation in the commit? ' ' . '[...]' seems hard to read, ' [...]' should do the job as well (line 1813 in [12414]).

comment:3 @nacin6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Discussed on #wordpress-dev. Done like that to make it obvious the space is there and is deliberate.


comment:4 @demetris6 years ago


LOL. My concatenation is rather unpopular. And I got rboren into trouble with it. :-D

From the wp-dev channel:

(6:43:37 PM) filosofo: uh, why ' ' . '[...]' in r12414 ?

(6:44:01 PM) filosofo: how is that better than ' [...]'?


(6:52:03 PM) rboren: filosofo: Thought about changing it but then thought it made the rather extraneous nature of the space more apparent.

(6:52:11 PM) rboren: Would like to just get rid of it though.


(7:01:24 PM) demetris: rboren: filosofo: re r12414 -- My patch split the string into two for the reason rboren said. To make it obvious where the space was added, and also as an indication to people hacking the code in the future, that this space is there on purpose; it is not a typo, for example. But I am not a coder myself, so I dont know if this is good practice.

comment:5 @filosofo6 years ago

echo implode(' ', explode(' ', 
'I' . ' ' . 'thought' . ' ' . 'the' . 'documentation' . ' ' . 'made' . ' ' . 'it' . ' ' . 'clear.'));

If some things are bikeshed issues, this is more of a bike tarpaulin issue. :) 

I'm glad some of you get to see conversations in #wordpress-dev.  All I see are dozens of people leaving and joining the freenode servers every five minutes.

comment:6 @sirzooro6 years ago

My suggestion is to add comment instead, describing that this space is important.

Note: See TracTickets for help on using tickets.