How to make child theme ignore a parent themes template

I have a childtheme of twentythirteen in which i want to use the same template for pages and the blogposts-overview. But in twentythirteen is a page.php and an index.php. So I need override both, meaning I have to do all edits twice.

Any elegant solution for that?

Related posts

2 comments

  1. Create index.php and format it the way you want.

    Then create page.php and load the index file with something very simple like:

    get_template_part('index'):
    

    Note: This is untested and I am not able to test this right now. If there is a problem, leave a comment and I will run proper testing later and get back to you.

  2. You can use the template filters to force a template for specific kinds of requests.

    In this example, we load the page.php template for the blog posts page:

    function home_page_template(){
        return locate_template( 'page.php', false );
    }
    add_filter( 'home_template', 'home_page_template' );
    

Comments are closed.