Is there a safe way to get the post ID inside the_title()
?
add_filter('the_title', "change_post_title");
function change_post_title($title){
}
I tried using global $post
and get_the_ID()
, but this won't work in some cases (e.g. on a single page where the_title()
is being called inside the navigation to link to the next post. global $post
and get_the_ID()
will reference the single post instead of the post that is being linked to.)
With get_page_by_title()
I'd have to spawn multiple queries to cover all post types.
Do I have to fall back to a custom query?