wp_get_archives(cat=id) <-- Any way to specifiy cat id in archives?

Posted by Matrym on Stack Overflow See other posts from Stack Overflow or by Matrym
Published on 2010-04-23T19:18:23Z Indexed on 2010/04/28 1:23 UTC
Read the original article Hit count: 600

Does anyone know how to specify an INCLUDE ONLY category using wp_get_archives? I would like to specify a category but then list results by month.

I've tried kwebble's plugin to no avail. I've also found the following on WP forums, but it appears to only exclude categories. Perhaps it can be modified to do include? Even given that, I'm not sure how I would call it...

Thanks in advance!

add_filter( 'getarchives_where', 'customarchives_where' );
add_filter( 'getarchives_join', 'customarchives_join' );

function customarchives_join( $x ) {

    global $wpdb;

    return $x . " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";

}

function customarchives_where( $x ) {

    global $wpdb;

    $exclude = '1'; // category id to exclude

    return $x . " AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id NOT IN ($exclude)";

© Stack Overflow or respective owner

Related posts about wordpress-plugin

Related posts about wordpress-theming