douwan7382 2016-11-17 14:23
浏览 10
已采纳

订购ACF Wordpress

I am having some trouble with ordering my output using Advanced Custom Fields in WordPress. they where working nicely before but I had to make some alterations.

So I need my list to order by the number of signups (meta field) and it was before, but now I have added another field it no longer orders them in a particular order.

    $posts = get_posts(array(
      'post_type'     => 'schools',
      'posts_per_page'  => -1,
      'meta_key'      => 'signups', 
      'orderby'     => 'meta_value_num',                 
      'meta_key'      => 'region',    
      'meta_value'  => 'SW1', 
      'order'       => 'DESC'                         
    ));

I have tried to lookup why but I am coming up stuck with it. So it is a leaderboard where by the highest number is at the top naturally and ascends down.

  • 写回答

1条回答 默认 最新

  • doubu4826 2016-11-17 14:28
    关注

    I actually figured it out now:

        $posts = get_posts(array(
          'post_type'     => 'schools',
          'posts_per_page'  => -1,
          'meta_key'      => 'signups', 
          'orderby'     => 'meta_value_num',                  
          'order'       => 'DESC' ,  
    
          'meta_query'    => array(
          'relation'      => 'AND',
          array(
              'key'       => 'signups',
          ),
          array(
              'key'       => 'region',
              'value'     => 'EA1',
          ),          
          )
    
        ));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接