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
- How to know what functions are hooked to an action/filter?
- 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 I Make a Theme “plugin-ready”?
- 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
- 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?
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- Conditionally call add_action depending on post_type?
- Set template based on query in URL
- Template tags for Buddypress
- Woocommerce – Hide a Column in Cart Table
- What is the action hook for an order that fails on frontend checkout in WooCommerce?
- Is it possible to track down Actions and Filters?
- Is possible dequeue/remove style from wp_footer() hook and add on wp_head() hook?
- 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
- New custom nev not working [closed]
- 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
- 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 can I add text to a specific ‘Edit Page’?
- remove_action not removing add_action from constructor
- 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
- How to access page variable inside action hook
- Insert Content Before div#main from the functions.php File
- Use has_filter on comment_post
- How can I edit comment meta value before it is saved?
- Display taxonomy with a maximum number of letters
- How to add description over forum list on bbpress root page
- How to hook into action/filter call
- output custom Posts on a Page
- BuddyPress – A hook available to hide custom born date on public profile view?
- Display custom product option in admin order details
- Replace Data In Post & Update Meta Field Post Is Saved
- style_loader_tag not changing stylesheet to preload
- Hook to change the site URL
- Save_post – Warning: Cannot modify header information
- Would like to use hook or filters to customize email templates
- Hook to add content after date in post?
- BuddyPress : how can I call the template WordPress would have chosen (template hierarchy)?
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- Customize plugin templates
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Passing a parameter to filter and action functions
- strange behaviour of template_redirect in IE8
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- Retrieving post ID from current page
- change output location of plugin function using a custom hook
- Given a page ID, how to display entire page (header/content/footer/sidebars) from a plugin hook
- How to add custom checkout field in user details mail template
- add query string to all pages after user logged in
- Apply function on all action hooks?
- Can you call a filter hook by “add_action”?
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- Ninja Forms: Front-End Forms, Post ID?