I am currently implementing a filter hook based on
the_contenthook. I need to retrieved the
$post->ID, unfortunately this value is not accessible (or not set already) within the hook call.
Although I noticed that calling
the_IDis working. But for my own regex purpose I need to actually retrieve the ID value rather that simply echo it.
For now, I am using
global $idto access the current post ID. But I feel this is not a clean approach since
$idis not supposed to be directly accessed that way.
What would you suggest as a clean approach to this problem?
- The topic ‘`$post->ID` not accessible within a filter hook’ is closed to new replies.