WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How To Keep Certain Categories from Showing as Latest Stories? (8 posts)

  1. cchestnut
    Member
    Posted 4 years ago #

    I work for a small newspaper that's switching over our website to WordPress. We have a specific category set up for Legals so that we can post them as articles on the site. But we would really rather not have them showing up on the front page with the other news. Is there a way to specify that posts made to that Category should not post to the front page as well?

    Even though I've been doing a lot of tweaking here and there to our Magazine Basic layout, I'm still pretty new to CSS and PHP, but I think this could be done using conditional statements, right? I set up a simple one just yesterday to rotate our ads, but I'm thinking this might be a big over my head...

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Is there a way to specify that posts made to that Category should not post to the front page as well?

    Yes - using a custom query.

    http://codex.wordpress.org/Function_Reference/query_posts

  3. cchestnut
    Member
    Posted 4 years ago #

    Thanks for the info! I'll give this a shot!

  4. cchestnut
    Member
    Posted 4 years ago #

    Okay, I found the place to put the code and I put together a code that I thought would work based off the examples on that page, but it returned the exact opposite of what I wanted: instead of removing Legals from the front page, it's now showing *only* legals on the front page.

    This is the code I used:

    <?php if ( is_home() ) {
    query_posts($query_string . '&category_name=-Legals');
    }
    ?>
  5. esmi
    Forum Moderator
    Posted 4 years ago #

    <?php if ( is_home() ) {
    query_posts($query_string . 'cat=-3');
    }
    ?>

    where 3 is the id of your Legals category. Note the minus sign...

  6. cchestnut
    Member
    Posted 4 years ago #

    Okay, this may be a stupid question, but where would I find the ID of my category then?

  7. esmi
    Forum Moderator
    Posted 4 years ago #

  8. cchestnut
    Member
    Posted 4 years ago #

    Thanks, it seems to be working now!

    I swear I searched the Codex for that info before I asked, but I came up with nothing. But I'm trying to get so much done on the site in such a short amount of time, that I guess I overlooked it.

    Thanks again!!

Topic Closed

This topic has been closed to new replies.

About this Topic