دیگر رسانه ها
Limit to specific category not working – مرجع علم و فناوری
Hi Ashley,
I’m trying to limit my archives to single category (“blog”) only but unfortunately I can’t make it. I was trying method from FAQ as well as exluding category (topic found here in support) but neither of these works.
I don’t know if something changed due to updates or am I doing something wrong. Some help will be highly appreciated! Code I dropped into functions.php :
add_filter('expanding_archives_get_posts', function(array $args) {
$args['cat'] = blog; // Replace with ID of your category.
return $args;
});
add_filter('expanding_archives_query', function(string $query) {
$category = get_category(blog); // Replace with ID of your category.
if (! $category instanceof \WP_Term) {
return $query;
}
global $wpdb;
return "
SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year, COUNT(id) as post_count
FROM {$wpdb->posts}
INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id AND {$wpdb->term_relationships}.term_taxonomy_id = blog)
WHERE post_status="publish"
AND post_date
There are still all posts from all categories visible.
Thanks!
Jakub
The page I need help with: [log in to see the link]
دیگر رسانه های کشور:
باشگاه خبرنگاران همسونیوز| آموزشگاه رسانه |ارتباط اقتصادی| ارتباط فردا|ارتباط فرهنگی|ارتباط ورزشی|تهران اقتصادی |تهران ورزشی|مرجع وب و فناوری|پایگاه خبری شباب |همسونیوز