I was wondering the same thing. I couldn’t find anything, so I tried to hack the plugin myself to accomplish that.
I know updates are a pain if you hack a plugin, but to do my job for now (until the author of the plugin releases a new version supporting this feature) I had to do it this way.
So for those of you who want wordpress popular posts to show popular posts from the categories the post you’re viewing belongs, here’s the code (anyone with better coding skills can fix it to suit WordPress coding standards):
Open file wordpress-popular-posts.php and around line 1547 or before the code:
// * categories
if ( !empty($instance['cat']) && $join_cats ) {
Add this:
$post = get_post();
if ( $post ) {
$categories = get_the_category( $post->ID );
$cat_count = count($categories);
$cats_ids = '';
foreach($categories as $category_pop) {
$cats_ids .= $category_pop->term_id.',';
}
$final_cats = rtrim($cats_ids,',');
$where .= " AND p.ID IN (
SELECT object_id
FROM {$wpdb->term_relationships} AS r
JOIN {$wpdb->term_taxonomy} AS x ON x.term_taxonomy_id = r.term_taxonomy_id
WHERE x.taxonomy = 'category' AND x.term_id IN({$final_cats})
)";
}
I hope someone finds it useful, as I did.
-
This reply was modified 8 years, 6 months ago by
CRE8.
-
This reply was modified 8 years, 6 months ago by
CRE8.
-
This reply was modified 8 years, 6 months ago by
CRE8.