• I would like to split up my feed into two categories (which are the same as the category tags I assign to posts.) The categories I want are news articles (let’s call that A) and updates related to my company (B). Really, I would just like A and B to be displayed on separate portions of the website, and I don’t know how to do that, or if it’s possible. I am currently using the theme “Bloggingstream 2.1.1” by WooThemes. Is there a way within this theme, or are there other themes, that allow you to split up the latest articles I’ve posted into two sections?

    Additionally, is there a way to split up the RSS feed so it also posts articles from A and B in separate feeds?

Viewing 8 replies - 1 through 8 (of 8 total)
  • basically you add a query_posts statement before the WordPress loop. If you want all posts from category A to display on a page who’s slug is ‘a-posts’ and all posts from category B to display on a page who’s slug is ‘b-posts’ and all other pages to display normally, you can do it by adding this before the loop in the page.php template

    the numbers I am using are made up numbers for the category ID’s of categories A and B. You use the actual category ID number in their place.

    if ( is_page('a-posts') ) {
      query_posts('cat=7');
    } elseif is_page('a-posts') ) {
      query_posts('cat=9');
    }
    
    /*  loop starts here - code will be similar to but likely not exact  */
    if ( have_posts() ) :
    while ( have_posts() ) : the_post();
    ...

    You can add a category qualifier onto any feed URL to include only posts from that category

    1) http://domain.tld/category/categoryname/feed/
    or
    2) http://domain.tld/wp-rss2.php?cat=33

    If you don’t know how to find a category’s ID # see this
    http://www.wprecipes.com/how-to-find-wordpress-category-id

    Thread Starter LS222

    (@ls222)

    Thank you so much- you explained everything very clearly. Unfortunately, I must be doing something wrong, because it isn’t working. I’m sure it’s something small, but here’s what I have:

    if my two page slugs are “in-the-news” and “other-stuff,” and the category IDs are 4 and 5, shouldn’t it look like this?

    if ( is_page(‘in-the-news’) ) {
    query_posts(‘cat=4’);
    } elseif is_page(‘other-stuff’) ) {
    query_posts(‘cat=5’);
    }

    I put it right before what I’m pretty sure is the loop, which starts:
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Any clue what I did wrong??

    Also, is there any way to split up the category feeds so two show up on the homepage? Or is it only possible to place them in separate pages?

    Thanks in advance!

    Thread Starter LS222

    (@ls222)

    Also, I just noticed that at the top of each post on the site, it now says:

    if ( is_page(‘in-the-news’) ) { query_posts(‘cat=4’); } elseif is_page(‘born-updates’) ) { query_posts(‘cat=5’); }

    …even though I deleted the code from the page.php template when I realized it wasn’t working.

    How do I get rid of it?? I can’t find it!

    Also, I just noticed that at the top of each post on the site, it now says:

    if ( is_page(‘in-the-news’) ) { query_posts(‘cat=4’); } elseif is_page(‘born-updates’) ) { query_posts(‘cat=5’); }

    When you put this code in the page.php in the first place, was it within a PHP block that started and ended with
    <?php and ?>

    What you are describing is php code being displayed as text rather then executed as PHP. The code must either be in its own PHP block, or else part of a larger PHP block.

    As far as the display of that code, are you using a caching plugin? Could you be looking at a cached version of the page?

    If not and its definitely gone from page.php then most likely it got entered in another file as well. Text that isn’t somewhere can’t display. You need to backtrack – retrace the steps you took and see if you find the issue.

    Thread Starter LS222

    (@ls222)

    Took some digging, but I found it. Thanks so much for your patience- I’m very new to this stuff, and trying to pick up what I need as I go. I put the code inside a PHP block, and when I did that and refreshed one of the pages, nothing at all on the page shows up. What the heck went wrong this time? I’m sure it’s something simple again. Any idea?

    Thank you very much for your help.

    Suggest you post your page.php code in a pastebin http://pastebin.com/ and post the URL here

    Thread Starter LS222

    (@ls222)

    Thread Starter LS222

    (@ls222)

    Code is pasted above. Any ideas? You’ve been a huge help already, and I’d really like to solve this so I can move past it. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Separating by Category’ is closed to new replies.