• 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 8 replies - 16 through 23 (of 23 total)
  • Thread Starter dcochran

    (@dcochran)

    Otto42,
    I understand what you’ve suggested. I’ve read all about pages, I’ve created new page templates, and I have selected these templates for new WordPress Pages.

    What these pages will not do is pull posts from multiple categories into the same page. This is what I want to be able to do.

    I know WordPress does not typically do this. I want to know if there is a way to make WordPress do this. Apparently I’ve got to do some hacking. How do I hack it and where?

    As for what kind of loops I am using — they are loops which begin like this.

    
    <?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    <?php if (in_category('5') ): ?>
    

    Each one is set to pull posts from a specific category. I have several of these loops running in the index.php, each with a different category number, and together they populate my homepage with multiple posts from multiple categories, each in its own section of the homepage.

    Now I want other pages, besides just the homepage, which also enable me to fill out the page with various sections, each section populated by posts from a different category. Thus, these other pages will, like my index, contain multiple posts coming from multiple categories. I am assuming these can’t be WordPress Pages, and they can’t be category archives — or if they can be, then I have to modify the way WordPress works.

    Where do I modify, and how?

    Thread Starter dcochran

    (@dcochran)

    moshu –

    That looks like it’s more on track. I’ll try it out and see …

    You can also search the forum, now that I understand what you want I remember similar threads.
    The issue is that WP recognizes Pages as Pages – meaning it knows that only ONE DB entry (post/whatever) should be shown on it.
    What you need, to tweak your queries in a way to set the “is_page” thing as false > so that WP will let you to display whatever you want.
    The solution I linked above seems to solve that AND keeping the beginning and the end of the file as a Page (in case you need conditionals based on that status).

    Sorry, I am not a coder, so I can’t give you code lines, but I think I understand how it works 😉

    Thread Starter dcochran

    (@dcochran)

    Yes! That’s the kind of stuff I’m needing. Thank you. I’ll dig around, try it out, and report back.

    I notice the WP credits are not showing.

    Thread Starter dcochran

    (@dcochran)

    Sorry. We’re working on the footer now and will get those in!

    I do want folks to know we’re doing this with wordpress. Just been trying to get the thing fully functional and lost track of that. Thanks for the prod.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You can have a Loop on a page that will show categories and posts and such. But you don’t get it for free.

    See, this loop:

    <?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    <?php if (in_category('5') ): ?>

    Is a normal loop. What you need is something where you specify exactly what you want. Try something more like this:

    <?php $my_query = new WP_Query('category_name=Your_category&showposts=10'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
      <!-- Do your loop here... -->
    <?php endwhile; ?>

    That is what I mean by a specific loop. You control the loop, from beginning to end, instead of trying to use the default loop created for you (which will get the Page content). With this, you get exactly what you specify, nothing else.

Viewing 8 replies - 16 through 23 (of 23 total)

The topic ‘Multiple Pages with Multiple Posts from Multiple Categories?’ is closed to new replies.