Home Forums General Issues ACF Order by not working


ACF Order by not working

  • I am trying to order posts on my category page from newest to oldest and then from A to Z using an Advanced Custom Fields variable “inductee_last_name”.

    Here’s my WP_Query:

    	$currentCategory = single_cat_title("", false);
    	$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    	$query_args = array(
    	  'category_name' => $currentCategory,
    	  'posts_per_page' => 30,
    	  'orderby'   => 'meta_value',
    	  'meta_key'  => 'inductee_last_name',
    	  'order' => 'DESC',
    	  'paged' => $paged
    	$the_query = new WP_Query( $query_args );

    If I remove orderby and meta_key, my query works just fine. But as soon as they’re added in. It doesn’t pull anything up.

    Any help would be greatly appreciated.

    Thank you.

  • Hi @sebastianmm

    I’ve just tested your code and it was working correctly on my end. Could you please make sure that you have “inductee_last_name” custom field on your post?


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

The topic ‘ACF Order by not working’ is closed to new replies.