Hi @alex856,
This feature is something that only a handful of people would use IMO and so I’m not too convinced that it should be added to the plugin. An add-on plugin (or even a simple PHP code snippet) can do the job but -again- it’s not something I would add to WPP.
If you’re a developer, have a look at the Query class. You’ll find some filter hooks in there that you can use to filter posts by the max. number of pageviews.
Hello Héctor,
many thanks for your response. Unfortunately I am not a developer. How can I filter that exactly? Many thanks.
Hey Alex,
I’m flooded with work at the moment (this time of the year is usually a busy one for us developers), if you don’t mind waiting for a bit I can lend you a hand with this. How long that wait will be I don’t know but hopefully not too long.
If this is something urgent though then you may want to consider hiring a developer instead so they can get this done for you ASAP (if you do hire one please let me know in advance so I don’t invest time in this.)
Hello Héctor,
thank you. I can wait. Thank you for your help.
Hi @alex856,
Alright so this code should do what you’re looking for. Add it to your theme’s functions.php file (or to a site-specific plugin) and you should be good to go:
/**
* Modifies WPP's database query so it returns
* only popular posts that have up to 1,500 views.
*
* @param string $where
* @param array $options
* @return string $where
*/
function wpp_limit_max_views($where, $options) {
if ( ! is_admin() ) {
$where .= ' AND pageviews <= 1500 ';
}
return $where;
}
add_filter('wpp_query_where', 'wpp_limit_max_views', 10, 2);
Note that if you’re using the Data Caching feature you’ll need to temporarily disable it, save changes, then enable it back (and save changes) for this code to take effect. Otherwise you’ll need to wait for the cached data to expire for WPP to run this code.
Please let me know if you have any questions, alright?