如何使用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