2017-12-14 2 views
3

내가 가장 좋아하는 콘텐츠를 정렬하는 코드가 있지만 지난주 월요일과 다음 주 월요일 사이에 가장 좋아하는 것을 표시하고 싶습니다. 그리고 게시물은 해당 기간에 게시되어야합니다. Tho 나는 게시 날짜별로 정렬하는 방법을 모르고 그 중에서 가장 좋아했습니다. 누구나 할 수 있다면 도움에 감사드립니다.가장 좋아하는 항목 By 이전 주 월요일과 다음 주 월요일

$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(); 
+0

데이터를 올바르게 받아들입니까? –

+0

아니, 나는 그것을 단지 좋아하는 사람의 수에 따라 정확하게 분류하고 있습니다, 날짜는 전혀 작동하지 않습니다. –

답변

0

좋아요. 누군가가 이것을 필요로하는 경우에 대비해서.

   <?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());    
       ?>