You can add the action on the init itself, just increase the priority of the add_action
call. The higher the priority the later the function is called.
add_action('init', 'retrieve_my_terms', 9999);
But my suggestion is that you should do these kind of things as late as possible, preferably just before the first time they are used. There’s an action 'wp_loaded'
which gets called after full wordpress has been loaded & ready to start working on the output. That action might work for you.
Related Posts:
- Using get_terms for custom taxonomy in functions.php
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- Init action and refresh page after form action
- delete_term is not working properly with add_action()
- remove_action on after_setup_theme not working from child theme
- Remove Actions/Filters added via Anonymous Functions
- Trying to use add_action and do_action with parameters
- Check if post is being published for the first time, or is an already published post being updated
- How to use the do_action () with parameter
- Perform an action when post is updated/published
- WordPress Theme Update Action?
- Extract image from content and set it as the featured image
- Do WordPress’ cron’s clean up expired transients?
- add_action in a function, is it possible?
- Using a private method as an action callback from within a class
- Refresh page after form action
- How to restrict actions and filters “properly” by conditions
- How to count number of functions attached to an action hook?
- Add action hook conditionally – only when home.php in use
- Using add_filter() in Widgets
- How can I tell if I’m on a login page? [duplicate]
- Formating the_terms() function output
- Change meta tags programatically
- Convert hyphen to underscore in permalinks
- Fatal error: Call to undefined function add_action() – an untouched problem
- How to hook into the quick edit action?
- Reuse variable in hook callback
- Call to undefined add_action() in theme’s functions.php
- WooCommerce add_action hook results in 500 error
- Get term slug by term id and then explode it
- Changing where my author box is printed
- Insert Content Before div#main from the functions.php File
- Suggest Users basing on User taxonomy
- How add body_class from wp_termmeta
- Use add_action within template
- Problem in using Customizer
- Problem with custom function when I go back with the browser
- Replace admin header logo with an image
- New checkbox in custom widget isn’t saving data
- How do I find the code executed when wp_head() is called?
- template_redirect action only firing if logged in
- Display ACF category image on archive and single template files
- Get URLs for AJAX Filter Checkboxes WordPress
- How to get taxonomy tree ids without running expensive loops
- How to use wp_enqueue_script properly?
- Issue passing action class to nested function. Admin Columns
- Does hook have an effect on increasing the page load?
- How to Override Page Template if URL matches query?
- Save_post – Warning: Cannot modify header information
- What is the earliest Hook a Script can use?
- How do I trigger WP CLI DB export using a PHP function?
- If has action not working as expected
- Modifying a WordPress Plugin
- post value to function with Ajax and jQuery
- Is_Page doesnt detect my page
- How do you insert code into the sidebar?
- How Do I Unhook This Parent Theme Function?
- How to show only specific category post by user role without plugin and restrict all other cats
- I am trying to set post terms to a custom taxonomy
- Postback redirect through add_action is not triggered
- use add_action in a shortcode (gravity form – WordPress)
- I want to customize the_posts_navigation function by replacing prev and next with images
- wp_footer hook causing text to show on bottom of page
- Remove action hook from Class, understanding OOP
- Why is the term of my current page not returning a slug?
- How to change form action of wp-login page with a function
- taxonomy_edit_form_fields output after term fields
- Which method is more correct for removing WooCommerce Extensions menu item?
- I’m getting invalid taxonomy in init action
- Taxonomy On Index Page
- WordPress hooks to call a function inside a construct
- Change post count on tag/terms pages to 10
- True parameter but jquery register in header and not in the footer with wp_register_script
- Only seems to be displaying one child when there are supposed to be multiple
- How to prevent multiple custom terms from being created
- Fatal error: Call to undefined function add_action() – an untouched problem
- Sending Messages Back to the Template After Processing?
- Pass arguments to function class with do_action()
- previous_post_link inside of a function?
- custom COOKIE on custom page
- What add_action reference should I be using or should I use do_action?
- Getting error while trying to use custom comment function
- Settings in functions.php used by a plugin
- Init hook for header send
- ISOTOPE – Missing/Invalid Arguement Get Terms
- function to return comma separated list of meta values
- Do something when user creates post (that’s pending)
- wp_get_current_user->user login returns %20 for spaces
- add variable to actions/functions across different files (woocommerce)
- HELP: Code To Check Status And Write Debug Entry
- Setcookie not setting cookies anywhere except admin
- How to get variable from other function inside class function using add_action for Ajax call
- Function attached to cron job not running but will run if called manually
- Put ACF function output code the_terms
- Submit CF7 form programmatically with WP-Cron?
- Overriding an existing filter
- disable a specefic sidebar when user is log out
- wp_update_post breaks my function
- is there a list of actions on WordPress
- Remove Actions/Filters added via Anonymous Functions