如何使用PHP在Wordpress CMS上按字母順序排列數組?排序數組按字母順序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()) : ?>
http://php.net/manual/en/function.sort.php – Calimero
如果要按字母順序對結果進行排序,爲什麼要通過「menu_order」命令檢索它們?爲什麼不在WP_Query的相關字段中指定字母順序? – FluffyKitten