وردپرس

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 <= now() AND post_type="post" GROUP BY month, year ORDER BY post_date DESC "; });

There are still all posts from all categories visible.

Thanks!

Jakub

The page I need help with: [log in to see the link]

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
---------------------------------------------
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

⭐ امتیاز مطلب: هنوز امتیازی ثبت نشده است
برای امتیازدهی روی ستاره‌ها کلیک کنید:
دکمه بازگشت به بالا