Untested, but I’d start with something like this:
add_action( 'wp', 'your_function', 3 );
function your_function(){
if ( is_page_template( 'some-template.php' ) ) {
if( some condition )
locate_template( array( 'some-other-template.php' ), true );
else
return;
}
else
return;
}
Related Posts:
- Is there an action hook that fires just before a template is loaded?
- Modify a function without editing template
- Passing a parameter to filter and action functions
- Difference Between Filter and Action Hooks?
- How to know what functions are hooked to an action/filter?
- Get a list of all registered actions
- How can I edit post data before it is saved?
- Trouble understanding apply_filters()
- Is there any action filter/hook for validating a custom field before publishing the post?
- How many filter/action hooks are healthy?
- Earliest hook to reliably get $post/$posts
- What does (10, 2) mean when used with add_filter
- How to only hook on Single.php after content?
- Valid characters for actions, hooks and filters
- How to check if a hook is hooked or not?
- Implementing advanced add_* function wrappers
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How do I Make a Theme “plugin-ready”?
- How to make post and comment count unclickable with dashboard_glance_items hook
- Hook into admin post list page
- Anyway to edit the titlebar of WordPress Widgets in the Admin area?
- Load different template file when condition met?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- About Hooks and Filters
- How to debug removal of rewrite rule flushing?
- When calling wp_title(), do you have to create some kind of “title.php” file?
- Should I use add_action(‘publish_post or add_filter(‘publish_post?
- Please explain me what the do_action does
- Is it possible to create an action hook using do_action() within add_action()?
- Use external link in the add sub menu
- How to add attributes to tag when template cannot be directly modified
- Too many actions/filters!
- do_action and hook methods
- How to get list of all hooks of current theme / plugin?
- Find variables available at a given hook
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- Define a function outside a class and call the function using action or filter hook
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- Conditionally call add_action depending on post_type?
- Set template based on query in URL
- Remove “Get Shortlink” button in admin of custom post type
- Template tags for Buddypress
- Woocommerce – Hide a Column in Cart Table
- Which has more impact on site performance? Template overrides or hooks
- Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?
- What is the action hook for an order that fails on frontend checkout in WooCommerce?
- Is it possible to track down Actions and Filters?
- When to use actions and when to use filters
- Is possible dequeue/remove style from wp_footer() hook and add on wp_head() hook?
- How can i do something after head like adding a hook for after head but before post
- Same Conditionals Not Working on Two Different Hooks
- How to call a function or method that is Namespaced using another plugin
- add filter login_redirect does not contain original requested redirect
- get_header and hook avoid normal call
- Accepted arguments value in hook functions
- how to determine how many and what kind of arguments are passed to hooks
- Can the wp_filter object hold multiple values with the same key
- How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?
- Which action hook to use for function?
- Namespaced action and filter tags
- apply_filters/do_action tag characters limit
- Extending body classes in front- and backend
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- Filter taxonomy admin pagination
- Insert term when page is published – avoid duplicates after edits
- New custom nev not working [closed]
- Capture post content before page renders
- What is the filter or hook to add admin controls to posts on the front end?
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- How to remove action with slashes and arrows?
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Get Time Taken By Each Action Hook in WordPress
- Changing WordPress core without hacking core
- if page is parent page redirect to first child with hook / polylang
- Comment search plugin
- Filter Posts from the Main Query
- Issue understanding and using WordPress filters and actions
- How do I override the search template in a plugin?
- Template filter for custom taxonomy terms
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- How can I output all apply_filters and do_action?
- How to get all queries’s results after they have executed?
- Override the WordPress core function wp_referer_field
- How can I add text to a specific ‘Edit Page’?
- remove_action not removing add_action from constructor
- Genesis – Adding custom hooks to display secondary navigation
- Hook add_attachment error
- Call to undefined function is_home() or any conditional tags
- Remove actions/filters that are set with create_function()
- Get The Caller (Plugin / Theme / Core) For All actions & Hook in WordPress
- Rewrite to load homepage for a different url
- Remove tags without a specific meta key from “choose from the most used tags”
- How to find list of all functions bind to a particular hook from my plugin?
- How to access page variable inside action hook
- wp_list_authors() returning the wrong member url
- Insert Content Before div#main from the functions.php File
- What is the action hook to use if you want to capture the new password during password change?
- Use has_filter on comment_post