As you’ve discovered, meta queries only work with the post meta table, it is indeed looking for a meta key of post_date
.
You can’t do timespan queries with a simple query, but we can accomplish this with a combination of a query for the meta key, and a posts_where
filter directly on the SQL to get the time span.
first, the filter function (from WP_Query):
function wpa57065_filter_where( $where="" ) {
// posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
then the query, adding then removing the filter immediately after:
$args = array(
'meta_key' => '_post_popularity',
'orderby' => 'meta_value_num',
'order' => 'DSC'
);
add_filter( 'posts_where', 'wpa57065_filter_where' );
$recent_popular = new WP_Query( $args );
remove_filter( 'posts_where', 'wpa57065_filter_where' );
if( $recent_popular->have_posts() ):
while( $recent_popular->have_posts() ):
$recent_popular->the_post();
// your loop stuff
endwhile;
endif;