If I understand it correctly, you would like to check your template right before loading.
I think the hook template_include
is the best place you could do it.
Because this is the last place to load the template in loading procedure.
Regardless plugin or themes functions.php, it will also work.
The following is proved to be working in theme functions.php
add_filter( 'template_include', 'q364016_check_template' );
function q364016_check_template( $template ) {
// your code
return $template;
}
Related Posts:
- How can I load a page template from a plugin?
- How can I add an option to the Page Template list from a Plugin?
- How to create custom home page via plugin?
- Dynamically override page.php or single.php with custom templates using function
- Is it possible for a plugin to register a page template file?
- Calling a function from functions.php in custom page/ blog post
- Build dynamic page from cURL (HTML page) response with plugin
- Load page template with custom content using a plugin
- How to Add Page Template from Plugin without Losing $this
- Dequeue theme stylesheets but keep widget styling on custom page template
- How to display non-page / post content
- Change template dynamically
- Problem with parameters in url and pagination
- Set page template programaticlly in plugin
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- Can Page Templates be Applied to Archive and Post Templates?
- Custom Plugin theme filter
- Remove sidebar on single page using plugin API
- my basic php code producing unexpected results
- Create page (not the post type) dynamically
- How to output functions from plugin inside theme
- Best way to distribute templates and code accross multiple wordpress sites?
- How to remove/replace current page template?
- Load php file with jquery in single.php
- How to save multiple values in custom post type from front end to back end
- Change Front page displays settings conditionally when user is online
- Can’t create a blank template
- Code to add template to page
- Page template compatibility with different themes
- Using a Page Template Not in Theme
- Find Any Theme’s page.php File
- REST API error in block editor for custom templates
- Generating Multiple Divi Pages from Database
- How to get the path to the current theme?
- Inserting Taxonomy Terms During a Plugin Activation?
- wp_mail is undefined
- How do you use the plugin boilerplate loader class to hook actions and filters?
- Contact Form 7: wp_mail doesn’t work after update to 4.6
- Gutenberg ServerSideRender is deprecated, how to work with new wp.serverSideRender component?
- How to: Rest endpoint returning empty object
- Ensuring a plugin is loaded/run last?
- Turn revisions off in plugin instead of config.php?
- Add an image gallery to a custom post type?
- Script to remove all inactive widgets?
- Disable $title in Plugin Options Screen?
- WordPress Localization and Templating
- DIR vs URI when defining a path to a file
- Why after a file is programmatically deleted, is there still a reference in the media library?
- JS / JQuery form validation in backend admin menus
- My new WordPress plugin version is not showing up in the plugin directory. It’s been 4 days what could the problem be?
- Is using register_activation_hook required?
- Synchronize Custom post type tags to WordPress default posts tags
- Tabbed navigation for plugin options using same row in database for all?
- Ethics question: what qualifies as a fork? [closed]
- How can I prevent my plugin’s next version from updating one of the files?
- How to i18n text coming from the db or from an external source
- Is there an action like ‘after_register_custom_post_type’?
- How to get results of subcategories also?(WP Rest Api v2)
- dbDelta using Foreign key not working on update [duplicate]
- Plugin widget zindex changes depending on theme [closed]
- Input value from metabox is not found in $_POST after post save
- CMB2 Form Throws No Input File Specified in custom WordPress Plugin
- Enqueue script globally
- Custom entity search and display
- Plugin README.txt isn’t updating in the Directory (stable tag is correct)
- post_title is empty on global $post object
- Can woocommerse be used dynamically for billing from another plugin for payment processing?
- How to properly package a block plugin
- How to create post favorite function without plugins
- Mock a dependency of a WP_REST_Controller class
- Remove All Taxonomies from Post On Update
- Plugin index page code executes multiple times
- Cleaning a filename after image sideloading a url that contains `%20`
- WordPress Plugin Development- When our plugin functions call?
- wp login redirect loop reauth=1
- WordPress Plugin Authoring question about jquery and css
- how to show youtube comment profile pic in wordpress
- When I activate my custom plugin the menus and some styling of my site is messed up
- How to create archive page to add in menu
- Query String Filtering API
- Gutenberg block breaks when showing new data
- Allow contributor user role to perform copy operation PHP
- How to use own css of functionality plugin?
- Get Custom taxonomy parent with wordpress REST API
- What to do with the .git folder in a WordPress plugin during local development
- Using the same class across multiple functions
- Change Label of custom post type
- Ajax Response Error | just getting error as the response
- admin-ajax.php returns “No Script Kiddies!” sometimes
- Widget won’t be activated
- Need to change buddypress profile url by add_rewrite_rule
- Generate activation url
- URL rewrite parameter lost (add_rewrite_rule)
- PHPUnit Ajax Serialization of ‘Closure’ is not allowed
- Settings API not Saving to Database or Display
- Error using @wordpress/create-block to create multiple blocks on Windows
- Upload to a specific media folder created by FileBird Lite
- Allow HTML in product attributes and variation for WooCommerce
- How do I modify the error code array used by “shake_error_codes” filter?
- How do I add multiple custom menu Woo-commerce my account page?