plugins - Order posts by meta key ( Using ACF )

Hey I am using ACF in media library and want to sort media by meta key (that is actually created by ACF). BUT it is not

Hey I am using ACF in media library and want to sort media by meta key (that is actually created by ACF). BUT it is not working.

Here is the code:

$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
         )
    )
));

for reference please visit this link.http://185.94.230.80/~wwwdevatta/artist-collection/294/

Hey I am using ACF in media library and want to sort media by meta key (that is actually created by ACF). BUT it is not working.

Here is the code:

$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
         )
    )
));

for reference please visit this link.http://185.94.230.80/~wwwdevatta/artist-collection/294/

Share Improve this question edited Aug 22, 2019 at 19:08 nmr 4,5672 gold badges17 silver badges25 bronze badges asked Aug 22, 2019 at 13:18 Atta Ur Rehman AkbarAtta Ur Rehman Akbar 214 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Use meta_value_num to order by numeric values

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745225360a4617435.html

相关推荐

  • plugins - Order posts by meta key ( Using ACF )

    Hey I am using ACF in media library and want to sort media by meta key (that is actually created by ACF). BUT it is not

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信