Support » Fixing WordPress » Post query displaying posts that meet 2 or more conditions

  • Resolved ameraz

    (@ameraz)


    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 …

    Any help will be very much appreciated!!
    Thanks in advance.

Viewing 1 replies (of 1 total)
  • 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
    ));
Viewing 1 replies (of 1 total)
  • The topic ‘Post query displaying posts that meet 2 or more conditions’ is closed to new replies.