【发布时间】:2015-07-28 23:24:17
【问题描述】:
无论如何似乎都无法运行:
$args = array(...);
$unitsQuery = new WP_Query($args);
function customCompare($a, $b)
{
return strcasecmp($a->post_title,$b->post_title);
}
$unitsQuery->posts = usort($unitsQuery->posts, 'customCompare');
if( $unitsQuery->have_posts() ) {
while($unitsQuery->have_posts()) : $unitsQuery->the_post();?>
<div><?php the_title(); ?></div>
<?php endwhile;
}
wp_reset_postdata();
没有调用排序,一切都工作得很好。我真的需要在查询后运行自定义排序。
【问题讨论】: