Forums
Home / Fixing WordPress / Post query displaying posts that meet 2 or more conditions
(@ameraz)
11 years, 7 months ago
I want to query posts that belong to a certain category and that have a specific meta_key to display a slider banner in archive pages.
So far I have this …
if ( is_post_type_archive() ) { $catid = get_query_var('cat'); query_posts(array( 'meta_key'=>'home-banner', 'posts_per_page'=>'3', 'cat'=>$catid )); }
… but it displays posts belonging to 'cat'=>$catid no matter if the 'meta_key'=>'home-banner' is present …
'cat'=>$catid
'meta_key'=>'home-banner'
Any help will be very much appreciated!! Thanks in advance.
damn!!!
the answer was so simple…
I was all right in the first place, the conditional was mistaken…
if ( is_archive() ) { query_posts(array( 'meta_key'=> 'home-banner', 'posts_per_page' => '3', 'cat' => $catid ));