由于你的问题没有说明,我假设这不是你的主要问题,而是一个单独的问题,告诉访问者一天中浏览量最大的页面。
因此,我认为WP_Query
课堂是你所需要的。
/** Query the posts to find the one with the most views from today */
$today = getdate();
$args = array(
\'meta_key\' => \'post_views_count\',
\'orderby\' => \'meta_value_num\',
\'posts_per_page\' => 1,
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'date_query\' => array(
array(
\'year\' => $today[\'year\'],
\'month\' => $today[\'mon\'],
\'day\' => $today[\'mday\']
)
)
);
$my_query = new WP_Query($args);
echo \'<pre>$my_query: \'; print_r($my_query); echo \'</pre>\';
/** Check for results and output them */
if($my_query->have_posts()) : while($my_query->have_posts()) : $my_query->the_post();
/** Your code goes here, inside The Loop */
echo \'<pre>\' . get_the_title() . \' (\' . get_post_meta(get_the_ID(), \'post_views_count\', true) . \')\' . \'</pre>\';
endwhile;
wp_reset_postdata();
endif;