[wp-hackers] by passing the entire template hierarchy

John Blackbourn johnbillion+wp at gmail.com
Mon Jul 7 15:24:50 UTC 2014


It sounds like you're trying to do something that doesn't belong as a
theme, but whatever. This should do the trick:

add_action( 'template_redirect', function() {
    locate_template( 'index.php', true );
    exit;
} );

Note that this will also affect feeds and things, so you might want to
add some `!is_feed()` logic in there if you still want feeds to work.

John

On 7 July 2014 16:08, Haluk Karamete <halukkaramete at gmail.com> wrote:
> Thank you guys for your input.. I appreciate it.
>
> John, I've built a new infustructure where things work differently and in
> this infrustructure, the whole theme is done by a single index.php. And
> that's always the case - which nullifies the need for the concept known as
> template-hiearachy.
>
> So there will never-ever be a need to say category.php.
> I do not wish to get into the details here as to why I]ve built a framework
> as such , and why I should or should not have done so etc.
>
> Please note that this is not about overwriting the template hierarchy.
>
> It's about totally by passing it
> - which I have a feeling is not possible.
>
> In the case of hooking into the "template_include" (or "template_redirect"
> for that matter), it's an overwrite.
>
> As you know, those hooks are run after wordpress core deployed the
> template-hierarchy and in some cases 7 or 8 files have already been probed
> for their existence. - which is exactly the process I'm trying to prevent
> from taking place.
>
> and as to the get_header option, Mikael, it's the same situation. By the
> time, get_header hook sees the world, all the file_exists operations have
> already been performed.
>
> Let me put it this way, we all know index.php is the last resort in the
> template-hierarchy.
>
> Is there a hook that I can turn index.php being the first-resort?
>
>
>
>
>
> On Mon, Jul 7, 2014 at 6:39 AM, John Blackbourn <johnbillion+wp at gmail.com>
> wrote:
>
>> It's a strange thing to need to do (you might want to re-think what
>> exactly it is you're doing) but it's simple enough:
>>
>> add_filter( 'template_include', function( $template ) {
>>     return locate_template( 'index.php' );
>> } );
>>
>> On 7 July 2014 10:34, Haluk Karamete <halukkaramete at gmail.com> wrote:
>> > Is there a way to by pass the great system known as the  WordPress
>> Template
>> > Hierarchy so that WordPress shoots the ball straight to the last resort
>> > which is index.php?
>> > _______________________________________________
>> > wp-hackers mailing list
>> > wp-hackers at lists.automattic.com
>> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list