Skip to content

Instantly share code, notes, and snippets.

@Frithir
Created June 25, 2015 23:46
Show Gist options
  • Save Frithir/871f2a397c1479bdae43 to your computer and use it in GitHub Desktop.
Save Frithir/871f2a397c1479bdae43 to your computer and use it in GitHub Desktop.
Wordpress Custom post type results template.
// Custom post type results template.
function template_chooser($template) {
global $wp_query;
$post_type = get_query_var('post_type');
if( isset($_GET['s']) && $post_type == 'directory_list' ) {
return locate_template('archive-directory.php'); // redirect to archive-search.php
}
if( isset($_GET['s']) && $post_type == 'resource' ) {
return locate_template('archive-resources.php'); // redirect to archive-search.php
}
return $template;
}
add_filter('template_include', 'template_chooser');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment