Hi @rami4625,
That’s not really possible without some custom coding work: you’d need to retrieve the IDs of the most popular posts from the last 7 days (you can use the \WordPressPopularPosts\Query class for this for example) and then pass these IDs to the second function using the pid parameter.
Thread Starter
Rami
(@rami4625)
Hi @hcabrera ,
Thanks for respond,
Can you give me specific example to do that?
That’s will help me more.
Thread Starter
Rami
(@rami4625)
That’s work but I should use (implode) to make it work,
The code now look like this:
<?php
if ( function_exists(‘wpp_get_mostpopular’) ) {
// Get Popular Posts IDs
function get_popular_posts_ids($range, $limit)
{
$post_IDs = array();
$query = new \WordPressPopularPosts\Query([
‘range’ => $range,
‘limit’ => $limit
]);
$popular_posts = $query->get_posts();
// Popular posts found, get their IDs
if ( is_array($popular_posts) && ! empty($popular_posts) ) {
foreach($popular_posts as $popular_post) {
$post_IDs[] = $popular_post->id;
}
}
return $post_IDs;
}
// Gets the 5 most viewed posts from the last 30 days
$post_ids_array = get_popular_posts_ids(‘last30days’, 5);
// Gets Each Item In $post_ids_array
$post_ids_items = implode(“,”, $post_ids_array);
wpp_get_mostpopular(array(
‘limit’ => 5,
‘range’ => ‘last7days’,
‘order_by’ => ‘views’,
‘stats_views’ => 0,
‘pid’ => $post_ids_items
));
}
?>