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
- Do WordPress’ cron’s clean up expired transients?
- add_action in a function, is it possible?
- How to count number of functions attached to an action hook?
- Add action hook conditionally – only when home.php in use
- 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
- How to hook into the quick edit action?
- Reuse variable in hook callback
- WooCommerce add_action hook results in 500 error
- wp_get_post_terms() returns WP_Error in functions.php but in template it works
- Adding a class to tag list in a function
- How to update feed only 2-3 times a week (for Feedburner email)?
- Make Categories a Dropdown Menu in Media Library
- Passing arguments to my function with do_action and add_action is not working
- Pass parameters to function through an action
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- Identical custom taxonomy slugs for same hierarchical children
- Don’t delete a page if it holds users
- How do I add Bootstrap and LESS to my migrated WordPress site?
- get_term and get_term_by return null or false, even though term exists
- How can I get my Script to work on the Login page?
- Setting posts_per_page for taxonomy term template
- Is there an alternative to get_template_directory_uri()?
- Wait a result before enqueue
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Multiple Loops Meta Data
- Is there a WP function to get taxonomy name from taxonomy_term_id?
- Get list of all custom tanonomy id
- Which functions/classes are available during SHORTINIT?
- Function added using `add_action()` not being called
- jQuery does not work
- Override the WordPress core function wp_referer_field
- Two functions with different arguments and add_actions, but identical code
- Remove a category from a post when saving a new post
- I can’t seem to install Font Awesome locally [closed]
- Scripts not loading when using the wp_enqueue_scripts action
- problem loading stylesheets to wp_head dynamically
- current_user_can comma list vs OR (||) list
- Hierarchical taxonomy list with modificated term links
- Add back in child theme what the parent theme removed with remove_action
- login_headertitle is deprecated since version 5.2.0
- Possible to merge these two functions?
- How to properly refresh page after form action?
- 400 Bad Request – JavaScript App calling Custom wp-json endpoint
- Get term slug by term id and then explode it
- Changing where my author box is printed
- Use add_action within template
- 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
- 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?
- 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
- 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
- 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
- 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
- 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
- Fatal error: Call to undefined function add_action() – an untouched problem
- Sending Messages Back to the Template After Processing?
- previous_post_link inside of a function?
- custom COOKIE on custom page
- Settings in functions.php used by a plugin
- Init hook for header send
- ISOTOPE – Missing/Invalid Arguement Get Terms
- 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)
- Setcookie not setting cookies anywhere except admin
- How to get variable from other function inside class function using add_action for Ajax call