Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
2  
have you looked at the template hierarchy? –  Milo May 18 '13 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. Thanks –  black_belt May 18 '13 at 20:56
add comment

4 Answers

up vote 2 down vote accepted

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

share|improve this answer
1  
Thank you for your easy solution :) –  black_belt May 18 '13 at 20:52
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.