[wp-trac] [WordPress Trac] #18037: inconsistency in filters for the_content and the_excerpt

WordPress Trac wp-trac at lists.automattic.com
Fri Jul 8 15:59:23 UTC 2011


#18037: inconsistency in filters for the_content and the_excerpt
-------------------------+-----------------------------
 Reporter:  opajaap      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Plugins      |    Version:  3.2
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 My plugin replaces a keytext by a div tag using a filter:
 add_filter('the_content', 'my_proc');

 This filter appears also to be run in an excerpt, while my div is stripped
 in the excerpt.
 When my div is stripped i want - instead of that div - to print a
 notification like - Here belongs my div -.

 So, either i need a boolean variable or function that tells me that my
 filter is currently run by a call to the_excerpt(), OR the filter should
 not be run on the excerpt if it is not added to the excerpts filter list.

 I tried a workaround by adding a new filter to the_excerpt and setting my
 own global to indicate i am in an excerpt, but unfortunately this filter
 is run after the the_content filter, despite fiddling with filter
 priorities. So, in a list (archive) the first excerpt is still in error.

 The documentation says about filters:


 the_content
     applied to the post content retrieved from the database, prior to
 printing on the screen (also used in some other operations, such as
 trackbacks).

 and

 the_excerpt
     applied to the post excerpt (or post content, if there is no excerpt)
 retrieved from the database, prior to printing on the screen (also used in
 some other operations, such as trackbacks).


 It appears that not only the_excerpt filters are run on the content if
 there is no excerpt, what is fine, but it works '''also the other way
 around:''' the the_content filters are run on the excerpt. This is an
 inconsistency, and basically my problem.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18037>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list