If you want your function to fire only once, you can use other hooks.
wp_head
might be useful in your situation since it is fired before the rest of the template is rendered.
template_redirect
is also fired before rendering the template.
If the sequence doesn’t matter to you, you can fire it at last using wp_footer
or get_footer
hook.
Related Posts:
- Where is the best place to use add_filter
- 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?
- Shortcode display outside the div
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Can a plugin add to header/footer/body content?
- Is it possible to add an action to the currently running action?
- Action on post publish
- How to add inline css/js inside a shortcode
- How to call bind function in wordpress actions or hooks
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- add action wp_head not working
- 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
- wordpress plugin is not activating from widget
- When to load auto-login code?
- How to get all of the activate_plugin action parameters?
- How to check current user before all actions and filters?
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Inject HTML meta tag inside wordpress tag using add_shortcode
- Add action to fire when a published post is updated
- How to pass variables to a function argument using add_action [duplicate]
- Submit Form data to another page via Ajax (WordPress Way)
- Does using `add_action( ‘init’…` cause performance issues?
- Hook for page Request?
- Custom CSS not being added by plugin
- How to use add_action for multiple instances of the same class
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- I cannot include a file in my plugin settings page
- Why do actions with class and public method don’t fire __construct()
- The function called on the wp head hook becomes null
- Nested Actions and Filters
- Passing function into add_action always returns the first argument
- Get post content inside plugin class method
- Remove action added in plugin class from theme
- echo plugin results on pages
- Plugin Hook: Get posts
- Is it possible to cancel a post status transition?
- How wordpress plugin hooks works? [duplicate]
- How to implement WordPress plugin update that modifies the database?
- WordPress Plugin Development In MVC Architecture, How?
- Customize plugin update “new version is available” text
- “Donate to this plugin” for WordPress.org Plugin Authors
- How to handel multiple checkbox field in the admin settings page with Settings API
- Update Multiple Post Meta for the Same Post In One call?
- How to show custom message once on plugin activation?
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- How to load a new template page according to a particular URL?
- PDF download – use wordpress functions
- API to filter new user registration $POST data?
- Set cookie then immediantly refresh the page
- How to add an attribute to the body tag with a plugin?
- Override the core function locate_template
- Set user ID at time of wp_create_user
- How to Create a Custom Plugin Permalink
- How would I go about creating a user ranked post popularity page?
- WordPress Backend HA (Automatic failover)
- Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?
- Custom post types – remove default post supports through empty array?
- How to insert and call new data in wordpress website database through a plugin
- How to be escape Variables and options when echo?
- Release the plugin in the WordPress repository where redux is used
- Dokan Marketplace store link in single product page
- Trying to add_action in a loop
- Using meta_query in a WP_Query not working for numbers properly
- Action on WordPress Install
- How to add captcha to publish widget
- How to add logo to a WordPress Custom Plugin?
- Use a custom block in another block
- Using OR Condition with facetwp facets
- How to copy the all WordPress media items to another custom plugin folder?
- Personality quiz in wordpress using a plugin
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- Error on plugin activation and creating new page
- Child theme modifications not showing up
- wp_remote_post To external API multiple values with the same key
- Function settings_fields() not recognized (Uncaught Error: Call to undefined function settings_fields())
- what’s different between wpdb->prefix and table_prefix
- Can we rename a plugin directory for a already launched plugin?
- What action or filter can I use to change all the html returned from server for a page?
- How to create a new database table whenever user changes options
- Am I correctly adding styles to plugin?
- How can I insert a record into a custom table from my custom form in my custom admin page?
- how to create table during plugin installation in side a class
- WP_Filesystem usage within a block of code
- Why function hooked using object are executing at all time?
- What is the Object for WP_Error Class?
- Ajax in Plugins: returns the whole page
- how to search through plugin in wordpress cimy-user-extra-fields?
- Any way to hook into WP after a page displays?
- is_user_logged_in() undefined at shutdown in plugin context
- What are Seeds? [closed]
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode