嘿,我在媒体库中使用ACF,想按元键(实际上是由ACF创建的)对媒体进行排序。但它不起作用。
代码如下:
$gallery_imgs = get_posts(array(
\'post_type\' => \'attachment\',
\'posts_per_page\' => -1,
\'post_mime_type\' => \'image\',
\'post_status\' => \'inherit\',
\'meta_key\' => \'serial_no\',
\'orderby\' => \'meta_value\', //or \'meta_value_num\'
\'order\' => \'ASC\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'gallery_ct_artist_cat\',
\'field\' => \'term_id\',
\'terms\' => $artist_id
)
)
));
请访问此链接以供参考。
http://185.94.230.80/~wwwdevatta/artist-collection/294/