Hiding selected categories

Community Forums Forums Design Tips and Tricks Hiding selected categories

This topic is: resolved

This topic contains 6 replies, has 2 voices, and was last updated by  Dorian Speed 1 year, 4 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #49384

    middayminer
    Participant
    Post count: 72

    Hi, I want to create a couple of categories where I can publish posts on but not have them show up on the homepage, is there a way to set their visibility that way? Googling shows me a plugin for this but it doesn’t look very compatible, plus it’s not listed on wordpress.org.

    Using the prose theme btw.

    #49404

    Dorian Speed
    Participant
    Post count: 140

    Which is it that you want to do – exclude posts that are in a particular category from the homepage, or not have the label for that particular category name show up beneath posts that are on the homepage?

    I am going to assume it’s the former, in which case you should add the following code to your functions.php file. (Make sure you do this via FTP and make a backup copy of functions.php before you make any changes, because it’s possible to encounter the White Screen of Death if you accidentally leave out a semicolon or other small errors when editing PHP.)

    if ( is_home() ) {
    query_posts( 'cat=-3' );
    }

    That would work for the category with the ID of 3. To easily see the ID numbers for categories, posts, etc., you can install a plugin called Reveal IDs that will add a column with the ID numbers.

    You can read more about how to implement this here on the codex.


    Bringing websites Up to Speed
    Firebug will light the way to understanding the secrets of the Internet!

    #49424

    middayminer
    Participant
    Post count: 72

    Hi Dorian, thanks for replying! :)

    Well, I think I have to defer on the file I should be editing, because the codex entry says I have to put the code in index.php

    Problem is, it still doesn’t work. I assume the index.php it’s referring to is the one directly in the wp-content folder? There’s one or two in the theme folders and thereabouts. Either I break the website, or get no change. http://www.foundwonders.com

    pretty much just using`

    
    <?php
    if ( is_home() ) {
    	query_posts( 'cat=-33' );
    }
    ?>

    To confirm, the category is indeed the one called ‘pending approval’, ID 33. I’m very likely just missing something obvious.

    Oh, and I have seen more than a few white screens since I started making the website, but always have a backup of the file handy. Very thankful that nothing has irreversibly broken yet.

    • This reply was modified 1 year, 4 months ago by  middayminer.
    • This reply was modified 1 year, 4 months ago by  middayminer.
    #49430

    Dorian Speed
    Participant
    Post count: 140

    Let’s see – so, did you try adding it to functions.php? Here’s another solution via Bill Erickson, WordPress/Genesis Genius.


    Bringing websites Up to Speed
    Firebug will light the way to understanding the secrets of the Internet!

    #49431

    Dorian Speed
    Participant
    Post count: 140

    Completely unrelated: if you’re using this to filter posts based on a workflow of some sort, I would recommend you check out the superfantastic plugin Edit Flow. It uses custom statuses and lots of other neat features to flag posts that still need approval/components before they’re ready for prime time. Here’s a nice overview that Suzette Franck did of the plugin and its various features.


    Bringing websites Up to Speed
    Firebug will light the way to understanding the secrets of the Internet!

    #49436

    middayminer
    Participant
    Post count: 72

    I did try it there just in case, and in custom code at well. No luck.
    This from the comments section of your link does work though!

    function exclude_cat($query) {
    if ( $query->is_home) {
    $query-> set('cat','-33');
    }
    return $query;
    }
    add_filter('pre_get_posts','exclude_cat');

    And indeed I am trying to sort out my workflow and other terrible things that get in the way of making content happen. Thanks for both the help and the tip! :)

    #49474

    Dorian Speed
    Participant
    Post count: 140

    Excellent! Glad you got it working the way you want. Feel free to hit me up for questions about Edit Flow if you do use it. You can mark this thread as resolved if your question was answered.


    Bringing websites Up to Speed
    Firebug will light the way to understanding the secrets of the Internet!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.