do_action
is an event and there are many of them throughout your WordPress instance, in the core or your themes and plugins. (Hypothetical) So even when you put an add_action
in your plugin file but the theme files are read first by order of execution your add_action
function will still fire at that event or time of the do_action
it is hooked to.
This is because even the theme files are held before they are executed by a WordPress Core hook called after_setup_theme
To know the order of all of these check out the documentation here
Essentially this means that all code should be inserted at some point in this action hook hierarchy, also you can create your own. So when adding code in a file you should be asking “when” in time is this executing? Have the theme files finished loading by this point? Has WordPress itself loaded yet? There are hooks for those things so be sure to read through that documentation
Related Posts:
- How can I edit post data before it is saved?
- When can you get current page ID and initialize hooks right after?
- Using the ‘draft_to_publish’ hook (post status transition)
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- How can I limit functionality in one version of a plugin?
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Failed to invoke other hook from the init hook
- Can a plugin add to header/footer/body content?
- Is it possible to add an action to the currently running action?
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- What are the benefit in adding hook in the init() hook?
- add_action in functions.php, do_action in plugin?
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- Any hook for pre-plugin-update -either bulk or single plugin update
- How to get all of the activate_plugin action parameters?
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Plugin Development – Functions or Hooks?
- Hook for page Request?
- Advanced WordPress plugin activation detection
- The function called on the wp head hook becomes null
- Passing function into add_action always returns the first argument
- Plugin Hook: Get posts
- Display_rows() and column_cb() strange behaviour
- Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates? [closed]
- Where to hook my plugin’s action
- Remove rewrite rules generated by plugin during deactivation
- How to pull code snippet from functionality plugin?
- How to use get_theme_mod in gutenberg editor wordpress?
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- My plugin wants to update another plugin
- Where (or when) should I register a new taxonomy?
- 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
- JS Support Ticket – Auto create WP account
- Input with spaces in Shortcode attributes overwritten by defaults
- wordpress plugin is not activating from widget
- Insert new user with form submit ‘init’ hook
- Edit Yoast SEO breadcrumbs output [closed]
- When to load auto-login code?
- How would I go about creating a user ranked post popularity page?
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- Using a post-signup hook to get user details
- Disable woocommerce cookies and delete cart data automatically
- Calling plugin function inside custom plugin for onclick event
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- How to check current user before all actions and filters?
- custom payment gateway in woocommerce failed to connect to remote api server
- Best way to maintain and update 3rd-party WP plugin when developer is unresponsive?
- Best place for short bio,image and button [closed]
- Custom plugin init action causing general slowness
- Customization API for plugin development
- Fromcraft Plugin On click submit button [closed]
- do_action() hook into load-(page)
- Howto check version of another plugin and then add a submenu page to it
- How to redirect users to their profile after they successfully edit their profile
- Inject HTML meta tag inside wordpress tag using add_shortcode
- How to get post ID with hooks publish_post, new_to_publish, etc
- Redirect to another page using contact form 7? [closed]
- edit_user_profile and show_user_profile are not firing inside a class
- Add action to fire when a published post is updated
- How to pass variables to a function argument using add_action [duplicate]
- Custom post types – remove default post supports through empty array?
- a weird attribute on every html tag
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Submit Form data to another page via Ajax (WordPress Way)
- the_post hook is not firing for me
- Why do plugins often ask to add in to templates?
- Does using `add_action( ‘init’…` cause performance issues?
- Create a post builder skin in a plugin
- remove_action not removing add_action from constructor
- How to get menu location in wp_update_nav_menu hook
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Plugin function inside custom plugin
- Are there action hooks for comments?
- How do I add $_SESSION[”] to my wordpress page?
- Loop in elementor custom widget not working
- WooCommerce: after install hook
- Save user total active time after login in wordpress [closed]
- How to remove a class function from a plugin by using remove_action()?
- Minimize and Uglify WordPress Plugin Files
- How to create a plugin that includes all the other plugins?
- wp_loaded with static Singleton
- Why is it important to check for isset and is_array before checking in_array in this example?
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- is it possible to hook every page style?
- Calling a save function from a “submit” button
- Add action to custom Function
- Action on WordPress Install
- Custom CSS not being added by plugin
- How to use add_action for multiple instances of the same class
- What hook can I use to modify custom post data before it is displayed on the page?
- How to hook into action/filter call
- Quick press publish post hook
- using wp_footer hook in a plugin
- Delete data from custom table when deleting a post
- Integrating Custom Database with WordPress