2017-09-14 1 views
0

어떻게 WordPress의 CMS에서 PHP를 사용하여 사전 순으로 배열을 정렬 할 수 있습니까?알파벳 순서로 정렬 PHP/Wordpress

<?php if(count($terms_array) > 0) : foreach($terms_array as $term) : ?> 

<?php 
    $term = ''; 
    $args = array(
     'post_type' => 'book', 
     'posts_per_page' => -1, 
     'orderby' => 'menu_order', 
     'order' => 'ASC' 
    ); 

    $books_query = new WP_Query($args); 
?> 

<?php if ($books_query->have_posts()) : ?> 
+1

http://php.net/manual/en/function.sort.php – Calimero

+0

검색 결과를 알파벳 순으로 정렬하려면 "menu_order"로 검색 한 이유는 무엇입니까? WP_Query의 관련 필드에 알파벳 순서를 지정하지 않는 이유는 무엇입니까? – FluffyKitten

답변

0

PHP의 기본 정렬 기능을 사용하십시오. 정말 당신이 할 수있는 배열을 정렬 PHP 함수를 사용

<?php 
sort($terms_array); 

if(count($terms_array) > 0) : 

foreach($terms_array as $term) : 

     $term = ''; 
     $args = array(
      'post_type' => 'book', 
      'posts_per_page' => -1, 
      'orderby' => 'menu_order', 
      'order' => 'ASC' 
     ); 
     $books_query = new WP_Query($args) 

     if ($books_query->have_posts()) : 
?> 
관련 문제