need to exclude a category

Support Forum Forums Plugin Support Custom Recent Posts Widget need to exclude a category

This topic contains 8 replies, has 2 voices, and was last updated by  mommysplurge 3 years, 8 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #93

    mommysplurge
    Participant
    Post count: 7

    i have some posts tagged with a category (it’s used for listing purposes when I add something new to my directory and it always is tagged with another category). can you help me exclude the category in the plugin code? i’ve done it everywhere else on my site that i need to except this one plugin!

    #94

    Prasanna SP
    Developer
    Post count: 120

    In includes/crpw-cat.php, search for

    get_categories('hide_empty=0');

    (it’s around 98th line) and change it to

    get_categories('hide_empty=0&exclude=123');

    , where 123 is the ID of the category to be excluded.

    #95

    mommysplurge
    Participant
    Post count: 7

    ugh i thought it worked but i didn’t test it (didn’t realize i didn’t have any recent posts that would be in the list). doesn’t work. to be clear, the posts to be excluded are tagged with a category that i WANT included as long as it is not tagged with the category that i DON’T want included.

    #96

    mommysplurge
    Participant
    Post count: 7

    this is what i do on entry.php so it doesn’t show up on the archive pages.

    <?php
    if (is_category()) {
    // assign the variable as current category
    $categoryvariable = $cat;
    
    // concatenate the query
    $args = 'cat=' . $categoryvariable . ',-162';
    
    // run the query
    query_posts( $args );
    }
    ?>
    • This reply was modified 3 years, 8 months ago by  Prasanna SP.
    #97

    mommysplurge
    Participant
    Post count: 7

    can i change

    ’category__in’=> $cats

    to append -162? (the category i don’t want)

    • This reply was modified 3 years, 8 months ago by  mommysplurge.
    • This reply was modified 3 years, 8 months ago by  Prasanna SP.
    #103

    Prasanna SP
    Developer
    Post count: 120

    Try this,

    In crpw-cat.php, change

    $crpw_args = array (
    	'showposts' => $number,
    	'category__in'=> $cats,
    	);

    (it’s in around 25th line) to

    $crpw_args = array (
    	'showposts' => $number,
    	'category__in'=> $cats,
            'category__not_in' => array( 162 )
    	);

    Note the use of category__not_in. I guess the 162 is the ID of category to be excluded.

    #104

    mommysplurge
    Participant
    Post count: 7

    no, didn’t work!

    #110

    Prasanna SP
    Developer
    Post count: 120

    Do you want to just prevent the category from being listed in the widget options, or do you want to exclude the posts tagged with that category even if the post is under another category? Am I missing something here??

    #111

    mommysplurge
    Participant
    Post count: 7

    #2 exactly.

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

You must be logged in to reply to this topic.