• Hi,

    In my theme, I have a home.php (here) which displays the 3 most recent posts under the ‘recent news’ section. I have also added a blog page (here) using a blog template I created which I also want to display recent posts. I have used the same code on both pages and both call content.php to display the posts. However, on the blog page, the post displayed is the page post and not the most recent posts. How can I rectify this?

    Any help would be greatly appreciated,

    Many thanks,

    Tom

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter tjphop

    (@tjphop)

    Sorry, here is the blog.php script and here is the content.php script.

    How are you using home.php, as the site Front Page</e> template, or as the Blog Posts Index template?

    In WordPress, the home.php template file is intended for the Blog Posts Index page, and not necessarily the site Front page. If you want to create a custom, static Front Page, the appropriate template file to use is front-page.php.

    So, if my guess is correct, you need to:

    * Rename home.php as front-page.php
    * Rename blog.php as home.php

    Thread Starter tjphop

    (@tjphop)

    Ah, I see. Thank you.

    And will the recent news section still display properly on my front page?

    Do you have your Front Page set to display your most recent posts, or a static page?

    Thread Starter tjphop

    (@tjphop)

    My front page (currently my home.php) is set to display my most recent posts but I would also like my blog page to do this.

    Is your blog.php a custom Page template? If so, are you pulling your blog posts into it manually?

    Thread Starter tjphop

    (@tjphop)

    At the moment yes.

    Changing my home.php to front-page.php works but now I want to get recent posts to display on a seperate blog page aswell.

    Okay then, don’t rename blog.php, as it is a custom Page template. Apparently, my guess was wrong. ??

    But, you might want to consider going the route of using a static Page as your site Front Page, as it might more easily allow you to accomplish what you want:

    1) Create a front-page.php custom Page template, with the same markup as your current home.php, with the custom “News” section.

    2) Remove your home.php template file.

    3) Create a static Page, e.g. named “Front Page”

    4) Create another static Page, e.g. named “Blog”

    5) Set your Front Page to display a static page

    6) Set “Front page” dropdown to “Front Page”

    7) Set “Posts page” dropdown to “Blog”

    Now, your Front Page will display your customized view of your most recent posts, and your Blog static Page will hold your Blog Posts Index.

    Thread Starter tjphop

    (@tjphop)

    Thank you very much. I did what you said and it works now. The blog static page takes the template of home.php by default so I did need to rename blog.php to home.php and remove the custom template tag at the top.

    Thanks again ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Recent news on home.php and another page’ is closed to new replies.