php 按对象属性对对象数组进行排序。示例:查询后对Wordpress帖子进行排序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 按对象属性对对象数组进行排序。示例:查询后对Wordpress帖子进行排序相关的知识,希望对你有一定的参考价值。

$the_query = new WP_query( 
  array(
    'posts_per_page'    =>    4,
    'meta_key' => 'featured_facts',
    'orderby' =>  'meta_value_num date',
    'order' => ASC
  )
);
      
function cmp($a, $b)
{
  return strcmp($a->menu_order, $b->menu_order);
}
usort($the_query->posts, "cmp");

以上是关于php 按对象属性对对象数组进行排序。示例:查询后对Wordpress帖子进行排序的主要内容,如果未能解决你的问题,请参考以下文章