2014-05-08 2 views
0

아래 코드는 알파벳 순서로 게시물을 내고 DATE까지 오름차순으로 정렬하려고합니다. 나는 usort() 또는 asort()를 사용해야한다는 것을 알고 있지만이 코드에 어디에 삽입해야하는지 전혀 모른다.날짜순으로 알파벳 순서가 아닌 오름차순으로 게시물 정렬

<?php    
$query_date = custom_get_query_date_full(0); 
global $more; 
global $num_posts; 
global $events_output; 
$section_class = 'section'; 
$events_output = ''; 

if(!isset($num_posts)){ 
    $num_posts = -1; 
} 

// no section given 
$args = array( 
    'post_status'=>'publish', 
    'post_type'=> 'event', 
    'posts_per_page' => $num_posts,  
    'meta_key' => 'date', 
    'orderby' => 'meta_value', 
    'dateOrder' => 'ASC', 
    'meta_query' => array( 
      array('key' => 'date', 'value' => $query_date, 'compare' => '>') 
      //,array('key' => 'page', 'value' => $post->ID, 'compare' => 'LIKE') 
    ) 
); 

$s = 0; 
$the_query = new WP_Query($args); 

if($the_query->post_count) { 
    echo "<ul>\n"; 

    while ($the_query->have_posts()) : $the_query->the_post(); 

     $alt_class = ''; 
     if($s%2 != 0){ 
      $alt_class = ' alt'; 
     } 

     $s++; 
     if($s == $the_query->post_count){ $section_class = 'section-last';} 

      $day_not_set = get_field('day_not_set'); 
      $date = get_field('date'); 
      $day = substr($date,6,2); 
      $day_html = "<span class=\"time-day\">$day</span>"; 
      if(substr($day,0,1)==0){ 
       $day = substr($day,1,2); 
      } 
      $month = substr($date,4,2); 
      $year = substr($date,2,2);    
      $month = custom_get_month_string($month); 
      if(!empty($day_not_set)){ 
       $day_html = "<span class=\"time-day\">20$year</span>"; 

      } 
      $terms = get_the_terms($post->ID, 'type'); 
      $terms_class = ''; 
      foreach($terms as $term){ 
       $terms_class .= "$term->slug "; 
      } 


      $events_output .= " 
      <li class=\"event-info $terms_class\"> 
       <time>$month $day_html</time> 
       <h2><a href=\"" . get_permalink() . "\">" . get_the_title() . "</a></h2>" . 
       str_replace('&nbsp;','',trim(get_field('teaser'))). " 
       <div class=\"readmore\"><a href=\"" . get_permalink() . "\">View ></a></div> 
      </li> \n"; 

    endwhile; 
    echo $events_output . "</ul>\n"; 
} 
?> 
<?php wp_reset_postdata();?> 

답변

0

내가 생각하는 :

'orderby' => 'post_date', 
+0

그것은 작동하지 않습니다.! 캐시를 지웠으나 운이 없다. –

관련 문제