WordPress Select template to render query in wordpress

Sometimes you want to use one archive template for different situations. In wordpress select a template by using the ‘template_include‘ filter. You have to use the function ‘locate_template()‘ ┬áto set the template.

This is if you want to stray from the normal way wordpress enables you to select a template. WordPress lets you create page templates in a way you can select them from a post (codex link). You can create custom archive pages for custom posts in a simular way (codex link). But what if you want to use an archive template for a page, or one template for everything…

WordPress select template


One Comment

  • Leave a Reply

    Your email address will not be published. Required fields are marked *