#32319 closed enhancement (wontfix)
the_content filter should provide reference to post
Reported by: | shramee | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.2 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description
the_content filter must provide at least post_id or if possible whole post object, so that contents of different posts can be filtered in a different manner...
Change History (5)
#2
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
It's also worth mentioning that this a template tag, which is meant to be used in the loop where the $post
global is accessible. In your filter callback, you can access the $post
global with $post = get_post()
. Closing as wontfix.
#3
@
10 years ago
I should clarify that while this hook doesn't always get evaluated inside the loop (via the_content()
, that was the original intent. In recent times since this hook was introduced in the very beginning of WordPress, it has been used for other purposes to simply format passed content. If you're using it in the loop, the $post
global should be accessible as outlined above.
And as @SergeyBiryukov aptly pointed out, it's not really feasible to pass that value to every instance of the hook because of the variety of situations it's leveraged in today.
Hi @shramee, welcome to Trac!
Unfortunately, a consistent fix does not seem feasible here. Even if we pass the post ID or object to all the instances in core, a lot of plugins and themes still use
apply_filters( 'the_content', $content )
without passing the ID.