Filter by active term
-
Hi,
First of all thanks for the great plugin. I’ve created a custom widget that will only show the most popular posts within the category of the active post:
$categories = get_the_category(); //get the category $active_category = array ( 'range' => 'last30days', 'order_by' => 'views', 'post_type' => 'post,exercises', 'limit' => 5, 'title_length' => 70, 'cat' => $categories[0]->cat_ID, 'pid' => get_the_ID(), 'thumbnail_width' => 200, 'thumbnail_height' => 200, 'stats_views' => 0, 'stats_date' => 1, 'post_html' => '<li style="margin-left: 0;"><div class="ba-pop-post"><div class="ba-pop-post-image">{thumb}</div><div class="ba-pop-post-info"><div class="ba-pop-post-title">{title}</div><div class="ba-pop-post-date">{date}</div></div></div></li>', ); // output the query wpp_get_mostpopular($active_category);
However, I’ve created a custom post type called ‘exercises’ and a custom taxonomy called ‘muscle groups’. I’ve already added the ‘exercises’ in the ‘post_type’ variable. I know I need to define ‘taxonomy’ and ‘term_id’ instead of ‘cat’, but how do I get the taxonomy and term_id dynamically, based on the active page? I’ve already tried ‘get_queried_object->taxonomy’ but that won’t work. Please help.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Filter by active term’ is closed to new replies.