Support » Plugin: Collapsing Archives » [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

    (@michaelingp)

    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

    (@michaelingp)

    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”.

    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.

    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.