Changing the template hierarchy

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

For instance;

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!

Replay

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' );

Category: php Time: 2012-08-30 Views: 1

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.203 (s). 12 q(s)