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

How loop through posts based on custom fields

$
0
0

I want to loop through posts and show only those posts for which the custom field
i.e _shopis not empty

I am always confused with meta query and even not sure that if this is possible using this or not . Following is what i have tried so far

$args = array('post_type' => 'jobs',
              'posts_per_page' => 12,
              'paged'=> $paged,
              'tax_query' => array(
                            array(
                                'taxonomy' => 'job_category',
                                'field'    => 'slug',
                                'terms'    => $term->slug,
                            ),
                        ),
               'meta_query' => array(
                              array(
                                'key' => '_shop',
                                'value' => '',
                                'compare' => '!='
                                )
                              )
                'meta_key' => '_shop', 
        );
$loop = new WP_Query( $args ); 

Viewing all articles
Browse latest Browse all 36

Trending Articles