Home Forums Front-end Issues order by ACF not working


order by ACF not working

  • Hello,
    I want to order some posts by download number desc, and it seems the articles are random displayed:

    $posts = get_posts(array(
    ‘post_type’ => ‘post’,
    ‘posts_per_page’ => 12,
    ‘meta_key’ => ‘post_views_count’,
    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘ASC’

    But strange, the mysql querry works just fine:
    SELECT * FROM wp_postmeta WHERE meta_key = ‘post_views_count’ ORDER BY meta_value DESC

    Any help is apperciated, thanks

  • How is ‘post_views_count’ updated?

    is this field a sub field of another field?

    Have you echoed out this value for each post to see if they are order by this value?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.