Wordpress get_posts attachments orderby

ⅰ亾dé卋堺 提交于 2019-12-25 00:36:54

问题


I am using this to get a list of all attachments of a post in Wordpress 3.2

 $args = array(
      'numberposts' => -1,
      'post_status' => 'any',
      'post_type' => 'attachment',
      'orderby' => 'title',
      'order' => 'ASC'
 );

 get_posts($args);

Nothing I do in the 'orderby' argument has any effect on the order in which the attachments are displayed. Can you order attachments by title? alphabetical order? in Wordpress


回答1:


Try sorting the returned array using array_multisort() and the 'title' key.



来源:https://stackoverflow.com/questions/8796265/wordpress-get-posts-attachments-orderby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!