1

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

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

2
  • 2
    have you looked at the template hierarchy?
    – Milo
    CommentedMay 18, 2013 at 20:40
  • @Milo Thanks for your reply, Yes I looked at the template hierarchy but didn't find any solution from there. But fortunately Bainternet has helped me to solve the problem. ThanksCommentedMay 18, 2013 at 20:56

4 Answers 4

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

0
    1

    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

      0

      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

        0

        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.

          Start asking to get answers

          Find the answer to your question by asking.

          Ask question

          Explore related questions

          See similar questions with these tags.