Advanced Category Excluder (ACE) plugin for WordPress

For a couple of days I was looking for a plugin for my blog, that can hide some categories, form the front page. After I discovered, that I need to hide them as well from the RSS feeds. And after I’ve figured out that what I want a plugin that I can control categories to be displayed or hidden, in different parts of the blog.

For example I’m planning to write technical articles in english. But I’m writing my blog in hungarian… And maybe most of people who are reading my blog won’t be interested in such technical subject, but those who are using my blog’s RSS feed maybe interested in technical articles.

So I’ve written a plugin for WordPress that can solve the problem mentioned above.
This plugin was written from scratch, but it has been inspired by Front Page Excluded Categories Plugin by Sean O’steen and Jason York.

Download here(1 Kbyte ZIP)

Details:

  • controls which category would appear in which part
  • handles empty categories
  • hides BlogRoll from category list
  • support for Event Calendar
  • works with WordPress 2.1, 2.2 and 2.3

“Advanced Category Excluder (ACE) plugin for WordPress” bejegyzéshez 37 hozzászólás

  1. Visszajelzés: DjZoNe
  2. Alapból 2 külön blogra kéne tenni a tartalmat. 😛 A személyes és a technikai tartalmat – ha ez többször is elő fog fordulni, főleg eltérő nyelveken – nincs értelme összekeverni.

  3. I’m pretty new to WordPress but this exactly wha tI am looking for. I have installed the plugin – and activted it- but I can’t see where in the dashboard that this plugin appears – where is that?

  4. Thanks for this plugin. It was what I was looking for!
    for those that are looking from where to set up this plugin, I’d suggest to have a look under Options- ACE!
    Regards

  5. Dude, brilliant! This is just what I was looking for to make my WordPress site work the way I wanted. Thank you.

  6. Hi! excellent plugin! but, i get this message when I try to use it on my blog:

    WordPress database error: [Not unique table/alias: ‘wp_post2cat’]
    SELECT SQL_CALC_FOUND_ROWS distinct wp_posts.* FROM wp_posts LEFT JOIN
    wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN
    wp_categories ON (wp_post2cat.category_id = wp_categories.cat_ID) LEFT
    JOIN wp_post2cat ON wp_post2cat.post_id = wp_posts.ID WHERE 1=1 AND
    category_id IN (3) AND (post_type = ‘post’ AND (post_status =
    ‘publish’ OR post_status = ‘private’)) AND wp_post2cat.category_id NOT
    IN (18) GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 1

    🙁 Can you help me?

    Thanks in advance.

  7. If you give a detailed bug report I’ll see what can I do about it.
    My blog is running under WP 2.3 and works perfectly for me.

  8. I think I have the fix for your plugin. On Line 41, the WHERE clause compares wp_term_relationships.term_taxonomy_id to your list of categories when it should probably be comparing the wp_term_taxonomy.term_id field.

    Thanks,
    Sean

  9. Hmmm, maybe not. It worked in the ‘front page excluded categories’ plugin. I’ll need to get my head wrapped around the control panel code and the ‘get_categories’ function.

  10. Sean is on the right track. The category numerical equivalents are in the wp_term_taxonomy.term_id field. That table must be part of the MYSQL request as well as the category rejection criterion.

    The category numerical equivalent and taxonomy equvalence table is wp_term_taxonomy. You cannot just look them up in the wp_term_relationships table.

    Looks like we are back in debug mode for a few days.

  11. Looks like a very useful plugin, but it doesn’t work on WP 2.3 for me 🙁 Hope you can figure out why. If I can be of any help – just let me know.

  12. Thank you Faro,Rirath, Sean, Jim and Karolis for your reports.
    The new version 1.0.3 is out. It’s available from wordpress.org 🙂

  13. I think I have figured out why the category is excluded sometimes and not others. It is because the SQL query selects for posts with tags OTHER than the ones you wish to exclude. So, if a posting has several tags, it WILL be picked up even though it is in the category you wish to exclude.

    For example (my category for exclusion is 15, and I hand crafted a mySQL query that returns the proper results — the query uses the mysterious ‘NOT EXISTS’ clause:

    SELECT SQL_CALC_FOUND_ROWS distinct wp_posts.* FROM wp_posts WHERE 1=1 AND post_type = ‘post’ AND (post_status = ‘publish’ OR post_status = ‘private’) AND NOT EXISTS (SELECT * FROM wp_term_relationships JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id WHERE wp_term_relationships.object_id = wp_posts.ID AND wp_term_taxonomy.term_id IN (15) ) ORDER BY post_date DESC LIMIT 0, 6

  14. I have changed the two routines ace_join and ace_where to the following code fragment with good results. These changes are not useful for earlier versions of wordpress. And may be entirely incorrect, but for me, right now, these seem to be what is needed.

    function ace_where($where) {
    global $wpdb, $wp_query, $targets;

    if (is_array($targets))
    {
    foreach ($targets as $key=>$val)
    {
    if ($wp_query->$key == 1) $filter = $key;

    }
    }

    $cats_to_exclude = get_option("ace_categories_".$filter);

    if ( !empty($filter) && strlen($cats_to_exclude) > 0)
    {
    if (empty($wpdb->term_relationships)) $where .= " AND $wpdb->post2cat.category_id NOT IN (" . $cats_to_exclude . ")";
    else {
    //$where .= " AND $wpdb->term_relationships.term_taxonomy_id NOT IN (" . $cats_to_exclude . ")";
    $where .= " AND NOT EXISTS (";
    $where .= "SELECT * FROM wp_term_relationships JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id ";
    $where .= "WHERE wp_term_relationships.object_id = wp_posts.ID AND wp_term_taxonomy.term_id IN (" . $cats_to_exclude . ") )";
    }
    }

    return $where;
    }

    function ace_join($join) {
    global $wpdb, $wp_query, $targets;

    if (is_array($targets))
    {
    foreach ($targets as $key=>$val)
    {
    if ($wp_query->$key == 1) $filter = $key;

    }
    $cats_to_exclude = get_option("ace_categories_".$filter);
    }

    if ( !empty($filter) && strlen($cats_to_exclude) > 0)
    {
    if (empty($wpdb->term_relationships))
    {
    if (!preg_match("/post2cat/i",$join)) $join .= " LEFT JOIN $wpdb->post2cat ON $wpdb->post2cat.post_id = $wpdb->posts.ID";
    }
    else
    {
    // if (!preg_match("/$wpdb->term_relationships/i",$join)) $join .=" LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) ";
    // if (!preg_match("/$wpdb->term_taxonomy/i",$join)) $join .=" LEFT JOIN $wpdb->term_taxonomy ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id";
    }
    }

    return $join;
    }

  15. I have installed this plugin on my blog running WP 2.3 and discovered an issue with it. When this plugin is activated on my blog it breaks the tag archive. For example if you were to try and go to http://yoursite.com/tag/foo/ while this plugin in activated, it results in a 404 error. However, as soon as I deactivate this plugin, the tag archive works fine if you go to the page http://yoursite.com/tag/foo. I like how this plugin was fixing my solution of needing to hide a category. The former plugin that I was using is no longer being developed and maintained so it broke with WP 2.3. I hope that we can get this issue resolved because I really would like to use the functionality that this plugin will allow.

  16. The same problem as David T. When plugin is activated, the tag archive is not working (404 error). When is not activated, all fine.

  17. Great plugin.
    QUESTION: Can I add a page to the five in my admin from which i can exclude posts??
    Thanks!

  18. The plugin works perfectly for me on WP2.3. However I miss one feature from the plugin I was previously using (Category Visibility), and that is the ability to prevent the names of certain categories from being included in the list in the sidebar. Is it possible to add this function?

  19. Hi Deb.
    This feature is available in the developement version on wordpress.org.
    Try it if you want to.
    It will be released in a week or so as version v1.1.

Vélemény, hozzászólás?

Az email címet nem tesszük közzé. A kötelező mezőket * karakterrel jelöljük.