#6284 closed enhancement (fixed)
add a the_post hook
Reported by: | Denis-de-Bernardy | Owned by: | |
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | normal | Version: | 2.5 |
Component: | Optimization | Keywords: | has-patch tested commit |
Focuses: | Cc: |
Description
Could we add a the_post hook, fired when the_post() gets called?
Its absence led me to this bug while investigating a workaround:
http://trac.wordpress.org/ticket/6283#preview
Thanks -- D
Attachments (1)
Change History (12)
#3
@
15 years ago
- Keywords has-patch tested added
- Milestone changed from 2.9 to 2.8
The purpose was (and still is) to apply filters conditionally on the post.
As a temporary workaround, I end up doing something like this:
on loop start, look at first post. if condition is met, remove all filters on the_content, except the one that checks the next post.
on the_content, look at next post, if condition is met, remove all filters on the_content, except the one that checks the next post, else restore the filters on the_content.
on loop end, restore all filters on the_content.
it's actually not all the filters, but much about. my purpose in doing so is to conditionally disable wpautop, texturize, etc. based on a postmeta's value.
#5
@
15 years ago
Worth a discussion.
Personally, I use setup_postdata() on singular pages to set a few <meta> tags in my page's header using WP's built-in functions. I might be alone doing this, and would of course fix this accordingly. :-)
Leaving it up to you to decide, as long as the hook is around.
#6
@
15 years ago
Couldn't that be done by using the_content
as an action with higher priority? Something like:
add_filter( 'the_content', 'my_function', 1 ); function my_function( $content ) { // add or remove filters for this post... return $content; }
It's not clear from your other ticket what you're trying to achieve and how it would be helped by this hook. Please could you supply us with further information.