WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Using Posts as News items on a static page on a 'CMS' site (9 posts)

  1. NFWRo
    Member
    Posted 3 years ago #

    Hi all

    I have created a CMS type site for a client that currently uses pages only on a theme I have created. The client has now requested that I include a News page that uses Posts as it's method of adding items.

    I am using wp-lists for my menus and the home page is set by including a home.php page in the theme. I gather that, to put posts into a static page, I should be able to add the new page (in this case News) and in the Reading pane of the WordPress Settings, set that to be the Posts page. However, as soon as I set the News page to be used for Posts, navigating to the News page just displays my home page. I'm a touch confused! Can anyone point me to where I might be going wrong?

    Thanks in advance.

  2. vtxyzzy
    Member
    Posted 3 years ago #

    Your question is not quite clear to me. Do you want to have blog posts show up as part of a static page, or just to have a separate blog page in an otherwise static site?

    When you set a page as the Posts page in Settings, it will use the file home.php if it exists. If you have used home.php as the name for your static front page, you will need to name it something else - frontpage.php, for example.

    Then, set that as the template for your static front page.

    Hope that makes sense.

  3. NFWRo
    Member
    Posted 3 years ago #

    Hi vtxyzzy
    Thank you for your reply. I'm sorry that I wasn't clear. This is a static site using the page template for all pages. However, I understood that to achieve a differently laid out home page I could put a home.php in and it would pick that up for the home page of the site.

    I understand what you mean when you say that the Posts page will use home.php (I thought it would use index.php) and can easily rename the home.php page, however, I am unsure exactly what method you refer to when you say set it as the template for the static front page?

    To answer your first question, I guess it is the first, the blog posts will be part of a static page called News that will appear on the menu bar.

    Thanks

  4. vtxyzzy
    Member
    Posted 3 years ago #

    First, you need to rename home.php to frontpage.php. Then you need to edit frontpage.php and add the Template Name comment at the front of the file like this:

    <?php
    /*
    Template Name: Front Page
    */
    ?>

    To set the renamed frontpage.php as the template, create or edit a Page and change the template from default to Front Page.

    Then, in Admin->Settings->Reading, set your new Page as the 'Front Page:' in the dropdown, and set News as the 'Posts page:'.

  5. NFWRo
    Member
    Posted 3 years ago #

    Hello vtxyzzy

    Thank you so much. That worked like a dream right up to my news.html as the Posts page. When not set as the Posts page it appears if I type in the URL. When set to the Posts page, I get a Remote server or file not found error, not, I have to say, a 404 error.

    As one way of fixing it, I've put my loop into home.php instead of index.php bearing in mind what you said in your last post about it using home.php, but it didn't work. Have I got the wrong end of the stick somewhere?

    Thanks

  6. vtxyzzy
    Member
    Posted 3 years ago #

    I am sorry, I did not realize that the news page is an html file. Create an empty Page titled News and use that as the Posts page.

  7. NFWRo
    Member
    Posted 3 years ago #

    The .html comes from the ".html on PAGES plugin" to help with continuity of SEO.

    I have tried disabling the plugin, but still get the same result viewing the page as just news in the url or news.html.

    Having said that, I did do exactly as you said. I created an empty page entitled News and set that as the Posts page. I currently have both an index.php and a home.php in my template folder that contain the loop.

  8. NFWRo
    Member
    Posted 3 years ago #

    Almost as soon as I sent the previous post, I wondered about the home.php being there, got rid of it, and it now works! Since yesterday I can't remember why I reintroduced it.

    Thank you so much for all your help - it's very much appreciated :-)

  9. vtxyzzy
    Member
    Posted 3 years ago #

    Glad you got it to work! Now, please mark this topic 'Resolved' using the dropdown on the right.

Topic Closed

This topic has been closed to new replies.

About this Topic