Title: [Plugin: Collapsing Archives] Problems excluding categories
Last modified: August 19, 2016

---

# [Plugin: Collapsing Archives] Problems excluding categories

 *  [michaelingp](https://wordpress.org/support/users/michaelingp/)
 * (@michaelingp)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-collapsing-archives-problems-excluding-categories/)
 * The first problem with excluding categories is that if a post is in two categories,
   the exclude will not work unless both categories are excluded. I would suggest
   that this is not intuitive, and is not the behavior of query_posts() which has
   a similar feature to exclude categories.
 * The second problem is that the SQL generated by the plug-in is not sophisticated
   enough to distinguish category terms from other terms in the taxonomy tables.
   As a result, there is a conflict with the co-authors-plus plug in, which uses
   the taxonomy tables to store co-authors. The result is if a post has co-authors,
   it will always appear in the archives even if it’s in a single category that 
   has been excluded.
 * My question at this point is does anybody have a fix for this? I like this plug-
   in a lot, so I’m going to try to improve it, but given my SQL skill level, it’s
   going to take some time, and I’d just as soon not re-invent a wheel.
 * Thank you. My apologies to the author if my analysis is defective.

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

 *  Thread Starter [michaelingp](https://wordpress.org/support/users/michaelingp/)
 * (@michaelingp)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-collapsing-archives-problems-excluding-categories/#post-1720706)
 * The second problem turned out to be rather easy to fix. Just add “AND taxonomy
   = ‘category’ to the SQL. So line 87 in collapsArchList.php becomes:
 * $inExcludeCatQuery =”AND $wpdb->terms.slug $in ($inExclusionsCat) AND taxonomy
   = ‘category'”
 * Since problem one has a work-around (just use one category per post if you want
   to exclude that category from your archives), I think I’m done.
 *  Thread Starter [michaelingp](https://wordpress.org/support/users/michaelingp/)
 * (@michaelingp)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-collapsing-archives-problems-excluding-categories/#post-1720710)
 * Hmmm… On reflection, I was worried what the new SQL would do if a post wasn’t
   in a category, but on testing, it appears, that at least in 3.0.1, every post
   is in at least one category, even if it’s in the category named “uncategorized”.
 *  [mishoo](https://wordpress.org/support/users/mishoo/)
 * (@mishoo)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-collapsing-archives-problems-excluding-categories/#post-1720980)
 * I have a problem too with excluding. When I exclude some category, it shows correct
   nubmer of posts in the brackets, but when I click to show me that posts, it shows
   all posts, even those from excluded category.
    Can someone help me, and tell 
   me the problem? Thanke you.
 *  [NickHardeman](https://wordpress.org/support/users/nickhardeman/)
 * (@nickhardeman)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-collapsing-archives-problems-excluding-categories/#post-1721159)
 * I was having the same problem with excluding. I came up with this quick solution
   for a project due tomorrow. I haven’t tested it too well, but it works for me,
   at least for the time being.
    Call the function by passing in the slugs for the
   categories to be excluded. for example:
 *     ```
       $args = array('inExcludeCat'=>'exclude', 'inExcludeCats'=> "portfolio,projects");
       collapsArch($args);
       ```
   
 * The problem is in collapsArchList.php around line 69.
    Replace the code from 
   lines 69 – 91 with the following.
 *     ```
       $inExclusionsCat = array();
       if ( !empty($inExcludeCat) && !empty($inExcludeCats) ) {
           if ($inExcludeCat=='include') {
             	$in='IN';
           } else {
             	$in='NOT IN';
           }
           $inExclusionsCat = "'".implode("','", explode(',', $inExcludeCats))."'";
       }
       if ( empty($inExclusionsCat) ) {
       	$inExcludeCatQuery = "";
         } else {
           $inExcludeCatQuery ="AND $wpdb->terms.slug NOT IN ($inExclusionsCat) AND taxonomy = 'category'";
        }
       ```
   

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

The topic ‘[Plugin: Collapsing Archives] Problems excluding categories’ is closed
to new replies.

 * ![](https://ps.w.org/collapsing-archives/assets/icon-256x256.gif?rev=2550328)
 * [Collapsing Archives](https://wordpress.org/plugins/collapsing-archives/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/collapsing-archives/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/collapsing-archives/)
 * [Active Topics](https://wordpress.org/support/plugin/collapsing-archives/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/collapsing-archives/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/collapsing-archives/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [NickHardeman](https://wordpress.org/support/users/nickhardeman/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-collapsing-archives-problems-excluding-categories/#post-1721159)
 * Status: not resolved