You can use a small tool on the category. php page to archive articles and filter articles by month. Q: This filtering is a full-site article. How can I filter only the articles under the current category (no gadgets are required, as long as they are implemented) in category. the php page uses a small tool to archive articles so that you can filter articles by month.
Q: This is a full-site article. How can I filter only the articles under the current category (no gadgets are required as long as they are implemented)
Reply content:
You can use a small tool on the category. php page to archive articles and filter articles by month.
Q: This is a full-site article. How can I filter only the articles under the current category (no gadgets are required as long as they are implemented)
add_filter('getarchives_where','current_category_posts_where'); function current_category_posts_where($where){ if(!is_category()) return; $category = get_the_category(); $term_taxonomy_id = $category[0]->term_taxonomy_id; global $wpdb; return $where." AND {$wpdb->term_relationships}.term_taxonomy_id = {$term_taxonomy_id}"; } add_filter('getarchives_join','current_category_posts_join'); function current_category_posts_join(){ if(!is_category()) return; global $wpdb; return "INNER JOIN {$wpdb->term_relationships} on {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id"; }
Add functions. php to the topic.
Purpose:
When you access the category archive (in your case, it's category. php) page, such as the http://www.test.com/category/uncategorized, only the posts under uncategorized will be counted.
Is this effect. Baixiaohei.sinaapp.com