• Is it possible to have multiple pages (or sections of the wordpress site) that display posts from multiple categories? My index does it great. I’ve used multiple versions of the loop in the index.php, each loop configured to display posts from a specific category.

    Now I want other pages in the site that can do it, too.

    We’re building a college student website. I would like for each major section of the site to be able to be laid out like we’ve laid out the current index page, with posts from this category in one spot, posts from another category in another, and so on.

    http://okwueagle.com/

Viewing 15 replies - 1 through 15 (of 23 total)
  • You’d basically do the same thing that you did in your index.php. Just create static .php files: academics.php, campus.php, etc., and insert your multiple loops to achieve the desired effect. That’s how I’d approach it.

    Thread Starter dcochran

    (@dcochran)

    Thanks. I’m trying that out. I’m having trouble.

    I’ve created a stepup.php based on index.php and saved it in the same theme folder as my functioning index.php.

    I have two problems:

    1) The URL to get to this file is very long and unwieldy.

    2) The template tags aren’t connecting to the database. I get an error on each bloginfo item in the head … and so I got read of those, replacing them with straight code. Now it gets to the loops, but the loops aren’t working. I get error messages every time.

    Fatal error: Call to undefined function: have_posts() in /home/.pause/okwueagle/okwueagle.com/wp-content/themes/okwueagle-spring07/stepup.php on line 14

    Here’s the URL to this file.

    http://okwueagle.com/wp-content/themes/okwueagle-spring07/stepup.php

    How can I solve these two issues?

    Thread Starter dcochran

    (@dcochran)

    Just checking back — Is there a way to do this?

    Thread Starter dcochran

    (@dcochran)

    Did I stump the community?

    I guess nobody really understands what you want – at least I don’t. So, instead of bumping just try to clarify what are the “multiple” pages. Until we understand the structure of your content… nobody will be able to say anything that would make sense.

    I think I get what he wants. You know how your front page shows multiple posts, usually the 10 most recent, and then you can click previous pages for more, can you have this for ALL pages throughout your website?

    nhlline,
    you are making it it even more confusing πŸ™‚
    If you visit the OP’s WP install – there is nothing similar to what you said.

    Can you make a page with more than one post? That simple.

    On a basic WP install – no. Pages (if we are talking about the same thing!) are meant to display ONE entry from the DB.

    Yes thats what I’m talking about. Thanks for clearling that up but why not, it would make wordpress that much better. And please refer to my post on “WordPress 2.1” I have a question in there that is frustrating me to no end.

    29 minutes (the time since you posted that topic) is nothing… in terms of WP forum. When you didn’t get an answer for 24 hours – you may start thinking why people didn’t get it, and add some more info πŸ™‚

    lol Thanks for the info

    Thread Starter dcochran

    (@dcochran)

    Thanks to all for jumping back in here with me.

    To try to make it more specific:

    My current index.php places posts of category sub-features within a sub-features div which I position in the top left sidebar. Under that I have a loop pulling posts of category announcements. Then I have a loop pulling posts of category features, which I’ve positioned at the top of the center column. Under features is a loop pulling posts from the category Homepage Highlights … and on it goes.

    Now I want MORE such files, in which I pull posts from multiple categories and place them in various places on the same web page. I do not need to create these as WordPress pages. I only want to be able to make a copy of index.php and change up the categories of the posts which get pulled in by the various loops.

    Besides index.php, I would like to have campus-life.php that does this, and academics.php, and eventually more. Each of these would have a complex layout, like my current index.php — placing posts from various categories in various places on the web page.

    I’ve tried this, but the loops don’t work. And when I place the file in the theme folder, the URL goes to the file in the theme folder (which is extraordinarily long and awkward), and the loops still don’t work.

    Is there a way to tell wordpress to treat these new multi-category template files like it treats index.php? — connecting it to an address on the main site structure (i.e., http://okwueagle.com/campus-life.php) — and allowing it to pull posts from multiple categories into various places in the same page?

    By the way, there is no 404 page working yet (I’m working on that), and so when you go to a page that isn’t there, you get the index:

    http://okwueagle.com/

    Thread Starter dcochran

    (@dcochran)

    And so to clarify, what I get when I try to do this as bryan868 first suggested is this.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Okay, you cannot connect *directly* to a theme file like that. There’s your first mistake.

    What we’re trying to figure out is how yowant people to actually access these extra loops. Where are they going to be? How are you wanting to link to them?

    You said I do not need to create these as WordPress pages., but in point of fact, yes, actually you do. Only WordPress pages can access WordPress data.

    If these extra php files you made have Loops in them that explicitly use get_posts or WP_Query or whatever to get what posts they want and such, then you should be able to simply turn them into Page Templates and then create new Pages (which will be empty) which use those Page templates. Then they will be accessible as standard WordPress pages.

    First read this:
    http://codex.wordpress.org/Pages#Creating_your_own_Page_Templates

    Next, turn one of your php files into a Page Template by adding the appropriate header to it.

    Then, create a new Page using Write->Page.

    Select your template on the right.

    Publish.

    Your Page will now be accessible at http://example.com/Pagename .

    Is there a way to tell wordpress to treat these new multi-category template files like it treats index.php? — connecting it to an address on the main site structure (i.e., http://okwueagle.com/campus-life.php) — and allowing it to pull posts from multiple categories into various places in the same page?

    See, you’re confused about the way wordpress works. It doesn’t magically turn links on the main site into links in the theme folder. The index.php on the main site *actually exists*. It loads the blog. In point of fact, it *always* loads the blog, regardless of what the URL is in the address bar. It uses URL rewriting, and the content of the address does not refer to the actual directory structure of the site in any way at all.

    Forget the old ways you know about putting html in folders and building a folder structure to create different URLs. WordPress does not work that way.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Multiple Pages with Multiple Posts from Multiple Categories?’ is closed to new replies.