Using `set_transient()` when saving a custom post type
Using `set_transient()` when saving a custom post type
Using `set_transient()` when saving a custom post type
Using Remove Action Hook in Plugin
Template_redirect works, but headers aren’t sent when checking via cURL
Session management issues with WordPRess 404 Error page
Filter wordpress posts without searching the keywords in the post content
This is not possible via those hooks. It’s too early. The reason it isn’t possible is because theme loading happens very early. There is no post to fetch yet, WordPress hasn’t processed the URL or created the main query. It’s so early that post types haven’t been defined yet. Even the init hook hasn’t happened.
Moving Javascript from footer to header
Rewrite the search page to use an appended slug + parameter
Filter widget_posts_args not working
You can provide the desired post ID to get_post. So inside your conditional, do the work to determine the post ID you need ($new_post_id), then use $post = get_post( $new_post_id ).