Changing the template hierarchy

Is there an easy way to change the WP default template hierarchy?

For instance;

Read More

Say I want to change my theme directory structure so that it completely changes from the Template Hierarchy suggested here based upon conditionals:

http://codex.wordpress.org/Template_Hierarchy

If I wanted to make sure that for all page types (is_single() is_home() etc) it always opens one template file which then instigates my own pattern to provide the output?

Thanks very much!

Related posts

Leave a Reply

1 comment

  1. Try this filter

    function wpse_63614_restructure_template_hierarchy( $template ){
        return get_template_directory().'/filename.php';
    }
    add_filter( 'template_include', 'wpse_63614_restructure_template_hierarchy' );
    

    The filename would be the file you would want to call in your theme folder. For child themes you would use get_stylesheet_directory instead.

    EDIT:

    Or as suggested by Chip Bennett and what I too feel would be better; you can use the template_redirect hook in the following manner. The priority can be set accordingly if required.

    function wpse_63614_restructure_template_hierarchy(){
        include( get_template_directory().'/filename.php' );
        exit;
    }
    add_action( 'template_redirect', 'wpse_63614_restructure_template_hierarchy' );