WordPress.org

Ready to get started?Download WordPress

Forums

Newbie theme design question (6 posts)

  1. thegreendesigner
    Member
    Posted 3 years ago #

    Morning all,

    I'm designing my first theme and I have a question regarding the correct way to do a task with posts and pages.

    The theme I'm trying to build has 4 pages:

    • home (home.php) - contains static text about my site
    • articles (index.php) - displays all posts
    • photos (page.php) - photo gallery
    • contact (page.php) - contact form

    The articles page is the one causing me all the issues. I want the articles page to display all my posts, displaying the last 10 posts at any one time but I can't get it to work.

    I've created a home page, set the home.php as it's template and set it as the static front page. I've also created an articles page, set the template to default (which I believe is index.php) and set it as the static posts page under the reading section of the admin page.

    The 4 page names make up the navigation along the top of my theme and all work as expected, except the articles page. The articles page displays the home.php template design without any content instead of the index.php page posts.

    Can anyone tell me how I create a theme which has 3 static pages and a posts page which is not on the home page?

    Thanks in advance,

    thegreendesigner

  2. keesiemeijer
    moderator
    Posted 3 years ago #

    Try giving the "Posts page" to a Page which uses the "Default Template" (template file: page.php) and see if that makes a difference. What Theme are you using?

  3. hoststadium
    Member
    Posted 3 years ago #

    shouldn't his home be index.php and should he have index.php grab a header.php and footer.php or can layouts be done differently then most of the themes that I have seen?

  4. keesiemeijer
    moderator
    Posted 3 years ago #

    I think you can only make a static homepage with a Page. If a static front page has not been set, then WordPress looks for a template file called home.php and uses it to generate the requested page. If home.php is missing, WordPress looks for a file called index.php in the active theme's directory, and uses that template to generate the page. So home.php is not a static page but the same as index.php. And you can't use index.php for a static front page (just Pages).

    What you can do is create your own page template: Homepage.php. Just duplicate the page.php and rename it to homepage.php. At the top of the homepage.php file, put the following:

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

    Make a Page with the static text about the site and use the "template" -> homepage.
    Set your just created page as the static front page and give the "Posts page" to the Page (articles) which uses the "Default Template"
    then you have

    * home (homepage.php) - contains static text about my site
        * articles (page.php) - displays all posts
        * photos (page.php) - photo gallery
        * contact (page.php) - contact form

    Articles page will now show all posts
    Home, photos and contact just one post (page).

  5. thegreendesigner
    Member
    Posted 3 years ago #

    Thanks that worked great.

  6. keesiemeijer
    moderator
    Posted 3 years ago #

    Glad you got it working! Now, please use the dropdown at top right to mark this topic 'Resolved'.

Topic Closed

This topic has been closed to new replies.

About this Topic