I’m currently coding a WP plugin and would need to override templates.
My filter hook looks like that – and it executes:
add_filter('template_include', 'mcd_set_template',10);
function mcd_set_template() just returns the required path as string – or the default WP template in case the file not exists.
I’m toying with this for hours already, even could include that alternate template (but it appears at the bottom of the page).
So my question is, how to force WP 3.2.1 to just load another template file instead – and which priority is required??
Update:
Also I noticed when using var_dump … it outputs almost at the end of the file – but should appear before the opening HTML tag…
According to this ticket it should work with template_include hook: http://core.trac.wordpress.org/ticket/11242
Or is the only way to hook these filters instead:
http://codex.wordpress.org/Template_Hierarchy#Filter_Hierarchy
?
Have you tried using an add_action instead? For example, you might want to try something like the following in your plugin:
Here is a helpful reference: http://www.mihaivalentin.com/wordpress-tutorial-load-the-template-you-want-with-template_redirect/