• Resolved joecat

    (@joecat)


    Hi, I’ve had a look around and tried a couple of things but can’t get exactly the behaviour I want.

    I would like the home page of the website to display some static text and optionally, say the excerpts from the last four posts.

    A separate news page will display the full posts.

    In the admin page, under Reading Settings, I’ve set the front page to display a static page (Front page = nothing selected; Posts page = News).
    This causes both the Front page and the News page to display the same thing – which I was hoping I could edit the behaviour of in the php.

    If I create a static page called “Home” and set that to the Front page, I get all sorts of things that aren’t as nice – the menu bar I have set up shows “Home” twice.

Viewing 5 replies - 1 through 5 (of 5 total)
  • I would like the home page of the website to display some static text and optionally, say the excerpts from the last four posts.

    If your home page is index.php you can:
    1. Alter the show posts per page to 4
    2. In the index.php file replace the_content() with the_excerpt().

    When you set the home page to nothing, it defaults to home.php(if you have this file) or index.php. When you set the Posts page to “News” you are simply telling wordpress that is like your main page for ALL your latest posts. Follow here.

    the menu bar I have set up shows “Home” twice.

    This is because your menu function is set to use the word “home” which merely represents what ever you have set for your home page. Thus, creating a page titled “Home” will result in duplicates.

    Thread Starter joecat

    (@joecat)

    OK, it seems it wasn’t too clear in my original post. My problem was that my news page was not displaying posts and I didn’t know how to do it.

    I want the posts to appear on 2 separate pages – on the front page as excerpts, and then in full on a News page.

    I had been working on the a couple of days and I think writing out my question clarified my thinking and I got it to work like this.

    I modified index.php to show only excerpts.
    In page.php, I added the conditional if (is_page(‘news’)) and then if it was, I displayed the posts.

    The downside is that I hardcoded the intro content on my homepage into index.php.

    Is there a way to to not hard code it?

    I was thinking this:
    1. Create a page called Home, where you can write the intro content.
    2. In the code that displays the menu bar, exclude the home page, so that it does not show up twice.
    3. Edit page.php to add a loop to display the excerpts if the page is “Home”

    The down side to this now is that your “Home page” is <base_url>/home and I would have to point my base url to this page.

    Both methods seem a little ‘hacky’ to me.
    How have other people solved this problem?

    I would have a news page which uses your news template, but has no content.

    The news.php template would query posts as index.php does. You can then use index.php (or, better way, set a static page and possibly use short codes for the excerpts).

    There are so many ways to do this, it is just personal preference!

    Let us know how you get on,
    ~Shane Hudson

    Thread Starter joecat

    (@joecat)

    Thanks Shane,

    That’s exactly what I needed. I’m finally starting to understand the use of various templates and I can see that there is definitely a few ways to do things – for example just using the index.php but using if statements to select the behavior depending on which page you are displaying. Like you said, it’s preference!

    Karen

    @shane: what do you mean by the personal preference? I don’t get it. Sorry but im a newbie of wordpress. thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress as a CMS – News page’ is closed to new replies.