gpt4 book ai didi

php - 按上一周星期一和下周星期一之间最喜欢和发布的顺序排序

转载 作者:搜寻专家 更新时间:2023-10-31 21:49:03 24 4
gpt4 key购买 nike

我有一个代码可以按最喜欢的内容对内容进行排序,但我希望它显示上一周星期一和下周星期一之间最喜欢的内容。帖子必须在该时间范围内发布。虽然我不知道如何按发布日期和那个时间范围内最受欢迎的排序。如果有人能提供帮助,我们将不胜感激。

$loop = new WP_Query(
array(
'posts_per_page' => 6,
'post_status' => 'published',
'post_type' => 'post',
'orderby' => 'meta_value_num',
'meta_key' => '_liked',
'date_query' => array(
array(
'after' => strtotime( 'monday previous week' ),
'before' => strtotime( 'monday next week' )
),
),
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
)
);
while ($loop -> have_posts()) : $loop -> the_post();

最佳答案

好的,刚刚完成。以防万一有人需要这个。

                <?php         

$loop = new WP_Query(array(
'posts_per_page' => 6,
'post_status' => 'publish',
'post_type' => 'post',
'orderby' => array('meta_value_num' => 'DESC', 'date' => 'DESC'),
'meta_key' => '_liked',
'date_query' => array(
array(
'after' => 'monday previous week',
'before' => 'monday next week'
),
),
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
));
while ($loop -> have_posts()) : $loop -> the_post();
?>

<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/


get_template_part( 'content', get_post_format() );
?>

关于php - 按上一周星期一和下周星期一之间最喜欢和发布的顺序排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47817186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com