WordPress.org

Ready to get started?Download WordPress

Forums

One of these pages is not like the other (4 posts)

  1. katyjack
    Member
    Posted 4 years ago #

    I'm using WordPress for a client mostly as a CMS -- the pages are the pages of the site and then I'm using the posts for a gallery of pictures she has. The problem I have is that the front page of the site looks very very different from the rest of the subpages of the site. Right now, I'm using page.php to create my subpages and index.php to create the gallery. How best to create to create the front page of the site and then tell WordPress that it's the front page? As a php programmer, I'm a beginner but I'm becoming an intermediate pretty quickly much to my dismay because I thought I wouldn't have to.

  2. Sayontan Sinha
    Member
    Posted 4 years ago #

    You can go to Settings -> Reading, then set your Front Page to be a static page from the drop-down. The pages in the drop-down will show up from the list of pages that you create.

  3. katyjack
    Member
    Posted 4 years ago #

    I guess I should have been more clear. I do know how to tell WordPress that it's the Front Page, what I don't know how to do is to make a page that looks very different from all the other pages. Do I need to create a new .php file to do that for just that page?

  4. Matty Cohen
    Member
    Posted 4 years ago #

    Hey katyjack,

    As I understand it, you would like a homepage that looks different to your subpage. If this is correct, you have two options:

    1. Use the is_front_page() conditional tag. Essentially, you would have both of the content layouts (homepage and subpage) in the page.php file. You would then run a conditional like this:

    <?php
    if ( is_front_page() )
    {
    INSERT FRONT PAGE CONTENT LAYOUT HERE
    } else {
    INSERT SUBPAGE CONTENT LAYOUT HERE
    }
    ?>

    This option only works if the layout isn't too different. If it's completely different, your other option is a custom template file.

    2. Custom template file. Create a copy of page.php and rename it to homepage.php, or something explanatory like that. At the top of homepage.php in the code, type:

    <?php
    /*
    Template Name: Homepage
    */
    ?>

    You now have a custom page template. :) In WordPress, edit the page that you are using as your homepage. In the "Attributes" box, select your new template from the "Page Template" select box.

    This should now give you a custom layout for your homepage. :)

    I hope this helps.

    Cheers,
    Matt.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.