How to make Home Menu( Front Page) use index.php instead of page.php

I needed a “Home” menu item in my wordpress website, so I created a new page and named it “Home”, added it to my main menu item and then from Reading Settings I selected the “Home” as Front Page.

Now the problem is, the Home is using page.php instead of index.php. I really need to get the home page using index.php as I have already designed the front page in my index.php

Read More

Could you please tell me how to make the home page use index.php instead of page.php

Related posts

4 comments

  1. The simplest way would be to duplicate your index.php in to a file named home.php in your theme’s folder.

    Another way would be to create a new page template same thing (copy index.php into it) and add this at the very top

    <?php
    /*
    Template Name: My Home Page
    */
    

    Then head over to the page edit screen and select “My Home Page” from the template drop down

    enter image description here

  2. You can use the template_redirect action hook.

    Add the following code to your functions.php file:

    if ( !function_exists( 'force_index_template' )) {
        function force_index_template() {
            if ( is_page( page_id ) ) { // Replace page_id with the page id of the home page
                global $template;
                $template = get_template_directory() . '/index.php';
                include( $template );
                exit;
            }
        }
        add_action( 'template_redirect', 'force_index_template');
    }
    

    Note: Make sure to replace page_id with the id of the home page.

    WordPress functions used: is_page, add_action

  3. select home page as Posts page in setting>reading.it’ll call you index.php.

    1.if you select home page as Front page ,it’ll follow page rule,so first search for front-page.php then page.php then index.php

    2.if you select home page as Posts page ,it’ll follow post rule,so first search for home.php then index.php

    read this may help you

  4. So a quick fix would be to backup index.php and rename your original index.php to something like page-home.php, that way you can retain all the changes you have already made.

Comments are closed.