There isn’t really a prescribed way to do this, but it’s probably safer to hook an action like init
to be sure everything you need is loaded, and then maybe check for some sort of flag so you can control which page loads run your code.
function my_test_func(){
if( isset( $_GET['do_my_test_thing'] ) ){
// your code
}
}
add_action( 'init', 'my_test_func' );
Then add ?do_my_test_thing=true
to the URL to explicitly run your code on that page load.
Related Posts:
- Best collection of code for your 'functions.php' file [closed]
- Shared functionality in plugins and themes
- Remote upload file to server B
- WooCommerce create new product and add to cart on form submit
- Post source link plugin – small modification
- Modifying Footnote Plugin for Descriptive Title Attributes
- How to Replace Words with Hypertext Link But Ignore Previously Existed Links?
- Override the filter from plugin in child theme
- Edit Yoast SEO breadcrumbs output [closed]
- Calling an attribute from a plugin shortcode
- Redirect to another page using contact form 7? [closed]
- Plugin Development – Functions or Hooks?
- Overriding an Array in a Plugin’s Class/Function from functions.php
- Change Header (Logo) Based on Login
- how to change wp-admin url using function file
- same user role or copy the user role to be same as the other role
- Call javascript functions from each page
- How to keep plugin (media-sync) running even the tab is closed?
- implement custom roles in custom plugin
- Post source link plugin – small modification
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Adding discount functionality to the cart
- How to assign a specific service to a specific provider based on location
- Precheck fields when I add a new post
- working code, not working – Plugin Dev
- Place content inside the Post Loop
- Conditional required fields for WordPress Contact Form 7
- WordPress: code structure
- How to Add Extra Text In WordPress Title Before Post Publish
- How to disable plugin capability : “create new category”
- Product customizing quiz – quiz adding products to the cart
- Should all plugins be encapsulated in a Class?
- How to include a plugin’s php file to another plugin functions file [duplicate]
- OpenID for WordPress 3.x? [duplicate]
- if plugin is active? check if plugin is enabled or not?
- How to override a theme function (within a class) using a plugin
- Seeking clarification on page request life-cycle
- How to assign user a role if none is present when logging in
- How to remove action from plugin?
- How to add product images using script?
- Setting up widgets in wordpress with a unique ID for the after_title argument
- How to find out what blocks are added by a plugin
- Use plugin or custom post type for game score functionality
- Copyright messages for a particular set of pages
- Where to place custom functions?
- AJAX button run function
- Do widget options need to be escaped widget()?
- Is there any W3C compatible Share & Follow plugin?
- Display post lists in 2nd paragraph
- creating html reusable blocks via shortcodes
- Fatal error: Call to undefined function cmsms_theme_page_layout_scheme()
- Getting Theme element into plugins page editor in wp admin
- Which file of wordpress manage plugins functionalities?
- Improving the perfomance of a plugin action
- JQuery prepend a function
- How to make a dynamic css class whose name changes every visit to confuse scraper
- I am trying to make a field show and save from quickedit screen
- Send email with list of active plugins upon activation/deactivation
- Using custom fields for image alt and title
- Where Should i write the code for wordpress ajax voting?
- Set up functions to be overridden without using function_exists() by short-circuiting them?
- Add action to custom Function
- Help with a function in a widget
- Widget where it can make changes to the container
- How do I create pages within a WordPress post?
- Custom Post Type, Custom Columns List
- How to prevent plugin, theme installation failures on WordPress?
- WordPress search input in database, to edit information via form and update the database
- Adding category base to url in custom post giving 404?
- WP Function does not trigger on Webhook API Call
- Alternative Hook to the_content for Changing Background Color
- Unpublished Pages Failing To Appear On Custom Path
- Can we hide a certain user in WP?
- How Can I Increase Breadcrumb Position Count (Starting From 2)?
- How to add specific script to WordPress webpage that will working with user input and databases
- Block plugin update possibilities (but not by hiding notifications)
- Execute function activate/deactivate plugin in specific pages
- Plugin function in child theme
- Load my Inline js footer area
- Move plugin upload folder from mywebsite.com/wp-content/uploads/pdfuploads to mywebsite.com/pdfs?
- Woocommerce list variations that are added already to cart in Single Product
- Flexslider empty slide
- Soflyy WP All Import Custom File Download Issue
- Share on social media created listing after submission
- Translation plugin with default language?
- Custom pages with plugin
- Changing the body of mail sent to new user registration
- Why isn’t my plugin seeing other classes?
- Which One Is Better For Managing Add Ons For Extensible Plugin?
- How to add submenu to WordPress plugin in the same Directory of main Plugin?
- Contact Form 7: custom validation [closed]
- functions.php conditional output for a single plugin
- Posts are deleted everyday at night
- Single dash converted to double dash
- How to declare this function correctly?
- What can I do to customize a widget provided with this plugin? from where have I to start?
- PHP if url extension action=discussion condition use [closed]
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- WordPress Convert queries to slashes using function.php