Hi there!
Question: are posts associated to two or more categories by any chance?
Yes, the post I was trying to exclude does have multiple categories. That was one of my original thoughts as to why it wasn’t being excluded from the list. I tested removing all categories other than the one I want to exclude and it still didn’t work.
-
This reply was modified 9 years, 1 month ago by
billcommexis. Reason: Reworded my response to be less confusing
That’s odd. It’s been a while since I last use the category exclusion feature so it probably is something simple to fix. I’ll run some tests and get back to you later.
I appreciate the help. Please keep me updated.
Any updates on this? I have a client that is still asking about this feature.
Hi there!
Sorry for the late reply. Last week was a hectic one.
Alright, for the test I added the stats_category parameter to $args to see the post category on the frontend and also removed the cat parameter, then ran the following code on localhost:
<?php
if ( function_exists('wpp_get_mostpopular') ) {
$args = array(
'limit' => 10,
'range' => 'monthly',
'order_by' => 'views',
'post_type' => 'post',
'stats_category' => 1
);
wpp_get_mostpopular( $args );
}
?>
Outputs:

Now, excluding the Random category using the cat parameter:
<?php
if ( function_exists('wpp_get_mostpopular') ) {
$args = array(
'limit' => 10,
'range' => 'monthly',
'order_by' => 'views',
'post_type' => 'post',
'stats_category' => 1,
'cat' => '-1'
);
wpp_get_mostpopular( $args );
}
?>
Outputs:

As you can see, posts associated to the Random category were filtered out. So:
- Are you running the latest version of the plugin?
- Is there a caching plugin installed on your site right now?
That new code seems to have worked. I appreciate all of the help!
Well, I really didn’t do anything. It’s basically your code with a couple of tweaks π
Glad to know it’s working anyways π
Dendi
(@thedeanamsterdam)
Hey man great plugin but i have the same problem as mentioned above, but i cant find where to put the code?…
I have a plugin that lets me categorize pages but i can’t include or exclude categories in your plugin now, i hope the code is the solution.
Thank you!
Hi @thedeanamsterdam!
Since it’s not the “stock” behavior in WordPress (pages are not supposed to use / have categories, that’s for posts and custom post types), WPP ignores the category filter when the post type is page.
Here’s a “cheat” that will surely work with the current version of the plugin: set the Post type(s) field to page, nonexistent_post_type where nonexistent_post_type is a post type that, well, doesn’t really exist π
P.S.: Be careful though, if I decide to add some sort of check for this in a future release of WPP this “cheat” will no longer be effective so I wouldn’t use this on a client’s project.
P.S.S.: I didn’t test it, so you’ll have to let me / us know if it worked or not.
Dendi
(@thedeanamsterdam)
nope when i add a category and save the widget, i come back and the category name is gone and not saved.
Dendi
(@thedeanamsterdam)
so i opened the widget and put page, nonexistent_post_type in the Post type(s) field. And than i want to include only one category, but the category dissapears after i save the widget
If that didn’t work then you’re probably out of luck. I’ll give it another shot tomorrow and if there’s anything else worth trying I’ll let you know.
Dendi
(@thedeanamsterdam)
okay please try one more time for me when you can, my site needs exactly what your plugin can do. Have a nice day!
Dendi
(@thedeanamsterdam)
btw the plugin works fine when i only add post,page but i really need the category’s