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.
Related Posts:
- What’s the earliest point I can get the queried object ID?
- Hook into theme-switching later than `setup_theme`
- Difference Between Filter and Action Hooks?
- How many times will this code run? (or, how rich is grandma?)
- Which hook should be used to add an action containing a redirect?
- add_action hook for completely new post?
- Hook in wp.media to add a new tab
- Add a new tab to WordPress Plugin install Listing
- Changing Plugin Load Order
- Admin settings update updating every time home page is hit?
- WordPress Hook for user register
- Overide get_template_part( ‘partials/post’, ‘sidebar’ ); with a plugin
- Global Objects and Public Methods
- Using filters and actions for plugin API?
- How should you hook a session_start() when authoring a plugin?
- Init action hook running late after PayPal’s return url?
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Explanation of the “posts_join” and “posts_fields” filter hooks?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How Do I Load My Action Earlier Enough?
- Does WP fire delete_post when trashed posts are automatically deleted?
- How do I Make a Theme “plugin-ready”?
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Using Primary Color in Plugin Block
- WordPress scheduled task is called but not executed
- Using a Theme inside a Plugin directory
- How to add a link to WordPress Plugin install Listing
- How to modify post content before writing to database?
- Plugin development without Theme adjustments?
- I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
- Call activation hook multiple times
- How do I handle multiple Submit buttons in plugin’s option page?
- What is the best way to provide plugin users with a way to customized the styles
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Two-step login process – Is it possible?
- How to check if certain plugin exists and in expected version
- Plugin development, hooks, generate content
- Is it possible to create an action hook using do_action() within add_action()?
- How can I hook into existing WordPress Bulk actions?
- Hook for post permalink update
- Dynamically Override Fancy Title
- Get returned variable from a function to add_shortcode function
- Programmatically Selecting Theme Based on URL
- Hook event for upload image in the menu
- Help with callback using do_action_ref_array
- How to properly use a hook to create template for custom product type in a plugin such as Woocommerce? [closed]
- Fully automated theme install and activation via a plugin
- Earliest WP Hook to Safely and Reliably Redirect
- Define a function outside a class and call the function using action or filter hook
- Is it possible to modify the media library admin screen?
- What function to hook for changes made in status and visibility of a post
- Create a plugin to change the action to which a function is hooked
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- Synchronize Custom post type tags to WordPress default posts tags
- Adding Automatically To In WordPress Using Filter Referencing?
- Order of Operation for these three hooks
- comment_email hook doesn’t seem to work for comment editor field
- Best Practices for Creating and Handling Forms with Plugins?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Modifying values with add_action to be sent to db
- Calling plugins API within a theme
- Woocommerce – Hide a Column in Cart Table
- unable to stop loop when using wp_insert_post with publish_post hook
- save_post hook not triggered in WP v3.6.1
- Add tab to profile.php wordpress plugin development
- Is it possible to delay execution of shortcode output callback?
- WordPress Ajax callback function from plugin – OOP
- Hook to get image filename when it is uploaded
- How to display a message about updates in the plugin list
- Why my database table not created on activation?
- add_action in functions.php, do_action in plugin?
- How do I change the initial quantity of a product in woocommerce?
- How to delete an user including data from custom database tables
- WordPress security issue to output data from user input from theme option form
- Act on user meta updated, but only once
- Where and how does WordPress store and use its plugin and hook information?
- Which themes do you use to test compatibilities with your plugin [closed]
- Is there any way to allow a plugin to write over a previous version?
- Which are the hooks run before/after when a category’s deletion?
- Should action callbacks start with a verb?
- Execute Hook on the footer or header after activating a plugin
- Why is my javascript not invoked in my hooks except wp_head?
- edit_{$taxonomy} | Hook
- WordPress after content Hook & external template part
- Namespaced action and filter tags
- What filter should I use to insert a button inside on Media>Add New
- best practice for query string values – get_query_var always empty for my value supplied in query string
- get_current_screen() return null
- Modifying meta tags after doing ajax call in plugin
- how to add custom functionality after woocommerce place order button
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- How to use a hook to override an update_post_meta call in a plugin?
- External Authentication, session_tokens not destroyed on logout
- Where to add hooks in a class
- Trying to understand order and frequency of action hooks firing
- How to use output buffering in WordPress hooked functions?
- Conditional hook based on the core function that is calling it
- Adding option to Gallery shortcode
- correct way to call javascript into hook function