template_include not loading -instead goes to index.php

I have the following code: <?php function ex_rewrite_rules(){ //discography query variable rewrite add_rewrite_rule( ‘artists/([^/]+)/discography/?$’, ‘index.php?album_artist=$matches[1]&discography=yes’, ‘top’); //albums rewrite rule add_rewrite_rule( ‘artists/([^/]+)/discography/([^/]+)/?$’, ‘index.php?album_artist=$matches[1]&discography=yes&albums=$matches[2]’, ‘top’ ); //songs rewrite rule add_rewrite_rule( ‘artists/([^/]+)/discography/([^/]+)/([^/]+)/?$’, ‘index.php?album_artist=$matches[1]&discography=yes&albums=$matches[2]&songs=$matches[3]’, ‘top’ ); } add_action(‘init’,’ex_rewrite_rules’); //Function to register query vars function ex_prefix_artists_query_var($vars){ $vars[] = ‘discography’; $vars[] = ‘album_artist’; return $vars; } add_filter(‘query_vars’,’ex_prefix_artists_query_var’); //function to load template … Read more

Custom Endpoint Gives 404 Header

I’m trying to write a general endpoint that loads a template. It works as expected with the small exception that the returned header is 404 – Page not Found. Am I missing something in my rewrites? Here’s how the rewrite looks currently: /** Register Query Vars **/ function theme_custom_query_vars( $vars ){ $vars[] = ‘map’; return … Read more

Render a different post/template from within the template_include action?

I am working on a webinar plugin that uses a custom post type to display the webinar pages. Those pages could be register, thank you, countdown, live etc. depending on the visitors registration status and the current webinar status. The plugin uses the template_include action to render content based on the current post status and … Read more

template_include for search.php makes WordPress think its on the home page

I have a custom tag-search feature, which allows people to search multiple tags to return relevant posts. Say they want to see posts that are tagged both ‘WordPress’ and ‘Tutorials’. I’m using the template_include filter, like so: public static function template_redirect( $template ) { if( isset($_GET[‘tag-search’]) ) { $template = locate_template( array( ‘search.php’, ‘archive.php’, ‘index.php’ … Read more

Use template_include with custom post types

I want to check for an appropriate template in the theme folder before falling back to the file in my plugin directory. Here’s my code: add_filter(‘template_include’, ‘sermon_template_include’); function sermon_template_include($template) { if(get_query_var(‘post_type’) == ‘wpfc_sermon’) { if ( is_archive() || is_search() ) : if(file_exists(TEMPLATEDIR . ‘/archive-wpfc_sermon.php’)) return TEMPLATEDIR . ‘/archive-wpfc_sermon.php’; return dirname(__FILE__) . ‘/views/archive-wpfc_sermon.php’; else : if(file_exists(TEMPLATEDIR … Read more

Methods of Integrating Plugin Data with Themes

I would like to get some opinions regarding the best practices for developing WordPress plugins that provide theme integration. In order to make sense as I ask this question, let me start with an hypothetical example of a scenario that I am curious about. Imagine that I create a plugin called “Discography”. Discography registers three … Read more

Is there any way to use get_template_part() with folders?

I’m wondering if there is any way to use get_template_part() with folders? My main folder has a lot of files now because I put every re-usable element in a separate file. I’d like to put them in folders then. There is no information about that in Codex: http://codex.wordpress.org/Function_Reference/get_template_part 3 In fact you can, I have … Read more