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
- Trying to use add_action and do_action with parameters
- How to use the do_action () with parameter
- Perform an action when post is updated/published
- 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?
- Refresh page after form action
- 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
- Fatal error: Call to undefined function add_action() – an untouched problem
- Reuse variable in hook callback
- Automatically Add Specified Value to Attachment Metadata upon Upload
- Can’t Update function.php after writing short code
- 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
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- How to select a page within admin?
- How to manage arrays from custom functions stored in functions.php?
- Identical custom taxonomy slugs for same hierarchical children
- 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
- Which action does wp_update_user triggers?
- How can I get my Script to work on the Login page?
- Setting posts_per_page for taxonomy term template
- Trigger a custom function when option are saved in admin area
- 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
- Get list of all custom tanonomy id
- Which functions/classes are available during SHORTINIT?
- Difference b/w Simple function call & do_action call
- jQuery does not work
- Override the WordPress core function wp_referer_field
- Set Taxonomy based on post status
- Two functions with different arguments and add_actions, but identical code
- Remove a category from a post when saving a new post
- add_action template_redirect not working for home page
- AMP – Change rel=”canonical” from functions.php [closed]
- Scripts not loading when using the wp_enqueue_scripts action
- Is there a way to prevent a function/method from being called outside a specific hook?
- Isotope Drop Down Categories Filter Function
- Missing argument for the function
- current_user_can comma list vs OR (||) list
- Adding code before post title with the_title produces weird results
- 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?
- 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
- How add body_class from wp_termmeta
- Use add_action within template
- Problem with custom function when I go back with the browser
- Replace admin header logo with an image
- How do I find the code executed when wp_head() is called?
- Display ACF category image on archive and single template files
- 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?
- 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
- Remove action hook from Class, understanding OOP
- Why is the term of my current page not returning a slug?
- 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
- 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
- Sending Messages Back to the Template After Processing?
- previous_post_link inside of a function?
- custom COOKIE on custom page
- Getting error while trying to use custom comment function
- Settings in functions.php used by a plugin
- 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
- How to get variable from other function inside class function using add_action for Ajax call