• Hi,

    I’m on the Readings Settings page, and have selected a “News” page as my Posts page. [Admin -> Settings – Reading].

    My question is this – how do I use a different template from the default here? I’ve created a template called page-news.php but can’t seem to get my news page to use it.

    Changing the template from the News page admin in the editor makes zero difference.

    Hoping someone can help!

    -ZB

Viewing 5 replies - 1 through 5 (of 5 total)
  • It sounds like you are already doing this, however just double checking.

    While editing the News page (in the editor) set the Template to whatever template name you gave page-news.php in its header comments.

    Info on how to set the header in a custom page PHP template
    https://codex.www.ads-software.com/Pages#Creating_Your_Own_Page_Templates

    If that is what you have already done, is it possible you unintentionally added the same custom page header to a second template file? The way that WP knows what templates you have available is by reading the file headers of all the files in the theme folder. So if two files have been given the same template name in the page header comments, results are unpredictable.

    Thread Starter Zaphod

    (@zaphod)

    Thanks for the reply, but as you guessed I’m already doing the things you suggest. I deleted the news page and recreated it again, doing everythign the same as before, and although I’m not quite sure why – it seems to have worked.

    I did this a number of times before it worked, so for now, I’ll presume I was just missing something…. but I don’t think so and now have my fingers crossed that it doesn’t break ??

    I think I’ll just leave it alone at this point!

    Thread Starter Zaphod

    (@zaphod)

    This issue has reared it’s ugly head again ??

    Basically when I create a page called News, and apply the template I want on in ADMIN, it works exactly fine.

    Now, when I then go to ADMIN -> SETTINGS -> READING and make that page the page for the POSTS page, and save, it goes back to using some other template. If I then change this page back to a normal page, it uses my template again just fine.

    Is this a wordpress bug?! It’s causing me huge problems…

    I guess I didn’t understand what you were saying the first time. For a posts page, WP would be using index.php as that is what is used on the posts page. You can modify that by adding a query posts statement into index.php. It can even be conditional.

    if (is_page(‘news’)) {
    query_posts(‘cat=7’);
    }
    ====== loop here =========

    That would cause WP to use either the category.php or archive.php templates.

    If you need full control over your posts page, don’t assign it as the posts page. Instead create a custom page template and control the display of what appears using query_posts

    Posts Page is more for having a full blown blog page.

    I have the same issue. I’ve created a website and want the homepage to be a static page using adminpanel -> settings -> reading. This page uses a special template file called home.php that is only used for this specific page.

    I changed the “posts page” to a page called “blog”, which should use the normal template I’ve created for my pages. However, this blog page now uses the same template as the homepage, which is not what I intended. Can this be changed somehow? Modifying index.php does not seem to do the trick…

    Does this have anything to do with my template for HOME actually being called home.php and WP prefers this one over index.php?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to get default posts listing page using a different template.’ is closed to new replies.