$popular_articles = get_posts(
array(
'numberposts' => $limit,
'category' => $category_id,
'meta_key' => 'views',
// 'meta_key' => '_recommended_all', // don't delete
'orderby' => 'meta_value_num',
'order' => 'DESC',
'suppress_filters' => false
)
//WP_Query Arguments
$args = array(
'date_query' => array(
array(
'column' => 'post_date',
'after' => '1 week ago',
)
),
'posts_per_page' => -1
);
//Execute WP_Query (Results placed in $the_query)
$the_query = new WP_Query($args);
//The WordPress Loop
if ($the_query->have_posts()) { //Check if there are any posts returned in $the_query
echo '<ul>';
while ($the_query->have_posts()) { //Loop through posts returned in $the_query
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else { //If no posts found
echo "No Posts Found";
}
//Reset WordPress Post Data
wp_reset_postdata();