Particular Category Archive Widgets & Page

Today i post how to show particular category archive Widgets and archive page. for that we will need to add some code in function.php and archiver.php

function.php


add_filter( 'getarchives_join' , 'getarchives_join_filter');
function getarchives_join_filter( $join ) {
    global $wpdb;
    return $join . " INNER JOIN {$wpdb->term_relationships} tr ON ($wpdb->posts.ID = tr.object_id) INNER JOIN {$wpdb->term_taxonomy} tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)";
}

add_filter( 'getarchives_where' , 'getarchives_where_filter');
function getarchives_where_filter( $where ) {
    global $wpdb;


    return $where . " AND tt.taxonomy = 'category' AND tt.term_id='category-id-number' ";

    }

put your category ID number in category-id-number

add bellow code before if ( have_posts() ) : ?> archiver.php


global $wp_query;
$args = array_merge( $wp_query->query, array( 'category_name' => 'blog' ) );
query_posts( $args );
Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *