• I have just set up a query like this

    query_posts( array( ‘category__and’ => array(630,35)));

    I have articles that are in both categories but the page doesn’t display anything.

    Can anyone please help?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Can you paste and submit the full code of the template file into a pastebin.com and post the link to it here? see the Forum Rules for posting code and using the pastebin.

    Thread Starter Colin Young

    (@cyoung75)

    Hi

    Sorry about that.

    <?php
    		query_posts(array( 'category__and' => array(630,35)));
    		while (have_posts()) : the_post();
    		the_excerpt();
    		endwhile;
    ?>

    I got it working, it was a mistake on my part. However, now I want to replace the 650 in the array with the category slug without me having to put the ID in myself.

    Is that possible?

    Moderator keesiemeijer

    (@keesiemeijer)

    If this is on a category page you can get the current category with this:

    <?php
    $current_cat = get_query_var('cat');
    query_posts(array( 'category__and' => array($current_cat,35)));
    while (have_posts()) : the_post();
    the_excerpt();
    endwhile;
    ?>

    Thread Starter Colin Young

    (@cyoung75)

    That’s excellent. I will try that when I get home.

    I haven’t heard of the get query var yet so will have a look at that as well.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘category__and in WP3.2.1’ is closed to new replies.