Unless a theme provides such a hook there is no way to do this with actions and filters. If a hook is provided then it will be theme specific, no generic WP solution exists.
For a full list of the hooks that a theme should implement, see here:
https://developer.wordpress.org/themes/advanced-topics/plugin-api-hooks/
At the moment this includes:
wp_head()
Goes at the end of the element of a theme’s header.php template file.wp_body_open()
Goes at the begining of the element of a theme’s header.php template file.wp_footer()
Goes in footer.php, just before the closing tagwp_meta()
Typically goes in the- Meta
comment_form()
Goes in comments.php directly before the file’s closing tag ()
section of a Theme’s menu or sidebar.
Note that aside from wp_head
and wp_footer
, there is no guarantee that the theme developer knew to add them, or did so correctly, particularly wp_body_open
and wp_meta
Related Posts:
- How can I see all the actions attached to an “add_action” hook?
- Which hook callback has priority if both plugin and theme use the same hook?
- add_action in functions.php, do_action in plugin?
- How to get menu location in wp_update_nav_menu hook
- Are there action hooks for comments?
- wp_login_form() ignoring login_form action hook
- Plugin Hook: Get posts
- Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- How to only hook on Single.php after content?
- How to get the active theme’s slug?
- When can you get current page ID and initialize hooks right after?
- Customizing subject in comment notification e-mails
- How can I log a user out of WordPress before the page loads?
- Check php version before theme activation
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- WP showing “warning: call_user_func_array()”, What to do?
- WordPress admin notice in plugin function
- Using the ‘draft_to_publish’ hook (post status transition)
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- WordPress Hook that will run when media file deleted
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- disable active plugins for specific theme
- Use external link in the add sub menu
- do_action and hook methods
- Is it possible to add an action to the currently running action?
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- Is it possible to remove this action? (as it’s added just before it’s called)
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- Uncaught Error: Call to undefined function get_user_by() after moving function from theme to plugin
- Can I use a method from an existing plugin as an action hook?
- Plugin custom Action Hook not working
- What are the benefit in adding hook in the init() hook?
- Reposition Woocommerce Message
- add_meta_box (Will display only in specific page admin WordPress)
- How to initialize something in unit test before the init hook being called?
- add action for displaying posts using a shortcode
- Deactivate Plugin on Theme Switch
- ‘wp_login’ action hook not working with wp-login.php file
- Where to hook my plugin’s action
- Prevent a plugin from being automatically activated
- How to Use Parameters with a Do_Action Function Within PHP Tags
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- WordPress filter that hook after each action/filter hook
- How to stop or remove an action being called inside a function of an extended class
- Automatically add attributes to woocommerce product?
- Any hook for pre-plugin-update -either bulk or single plugin update
- wordpress plugin is not activating from widget
- Insert new user with form submit ‘init’ hook
- Hooking in to replace the Sidebar/Widget areas
- How to get all of the activate_plugin action parameters?
- wp_get_post_terms is difference obj model than the one in rest api response
- Calling plugin function inside custom plugin for onclick event
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Removing an action from wp_footer called in a class that’s inside a bigger class
- All sites themes functions.php have been changed
- Why namespaces are rarely used in WordPress plugins?
- How to get post ID with hooks publish_post, new_to_publish, etc
- What is @Action in WordPress?
- edit_user_profile and show_user_profile are not firing inside a class
- My single.php page does not show the related data to the post which is clicked
- Use a hook or filter, or overwrite this Gamipress function?
- Hook from plugin doesn’t fire up from external PHP script
- WordPress Custom Hook with Class method
- Replace old theme that understand old css (vcex_icon_box css_animation)
- update_option_{$option} not working (do function after options are saved)
- Callback hooked to post_updated firing on new posts as well
- Remove a div class with condition
- The function called on the wp head hook becomes null
- How to get a post views count using ‘WordPress popular posts’ plugin
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- What is the process for reimplementing a back up WordPress?
- change output location of plugin function using a custom hook
- Template from scratch: Sidebars not showing widget
- Display static pages instead of category, in code
- OOP Plugin: Where should I place the action hooks in the class?
- add query string to all pages after user logged in
- How wordpress plugin hooks works? [duplicate]
- wordpress illegal string offset ‘parameter’ error
- Two sites one PC
- Hook automatic_updates_complete to autoupdate plugin
- Can’t use updated variables in handle function
- Real estate schema markup not showing up on Rich Results test
- add_action() not working for admin
- WordPress : how to create onglet and remove it when only one
- WordPress Action Hook inside Classes
- wp_head filter not executed inside custom class
- I have issue to retrive post thumbnail with rest api
- Remove H1 title in admin post edit screen
- Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1
- Remove 3rd party plugin notices from within own plugin
- How to customize WP_Error (REST JWT authentication plugin) [closed]