Quantcast
Channel: Question and Answer » meta-query
Viewing all articles
Browse latest Browse all 36

Advanced WP_Query with meta_query, orderby?

$
0
0

I wonder if anyone can help me with this little complex query with ACF.

I have the following so far which should display:

  • Pages,

  • News Articles,

  • About Articles and

  • Involved Articles.

  • Show: only 4.

Only display if: the ACF/Meta Key ‘home_page’ is selected ‘yes’

AND

Order by the numeric value of the ACF/Meta Key ‘home_order’ i/e 1,2,3 first, second, third etc

      $args = array(

                'post_type' => array( 'page', 'news-articles', 'about-articles’,'involved-articles' ),
                'showposts' => 4,
                'meta_query' => array(
                         'relation' => 'AND',
                             array(
                                                 'key' => 'home_page',
                                                 'value' => 'yes',
                                                 'compare' => 'IN',
                             ),
                                         array(

                                                 'orderby'   => 'meta_value_num',
                                                 'meta_key'  => 'home_order’,

                            ),
                 ),

            );

I think something is going wrong with the ‘compare’ and ‘relation’


Viewing all articles
Browse latest Browse all 36

Trending Articles