• I would like to know how to merge several queries into one. Now I do several query_post but I should be possible with just one.

    For example:

    (show a certain post)

    $args = array(
    	'p' => 3
    )

    AND

    (show the latest 25 posts)

    $args = array(
    	'showposts' => 25
    );

    AND

    (show posts in categories at all times)

    $args = array(
    	'category__in' => array(6,7,41)
    );

    Thanks in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • Based on what you’ve posted above:

    $args = array(
    	'p' => 3,
    	'posts_per_page' => 25,
    	'category__in' => array(6,7,41)
    );

    but that wont work as you’re asking for both a single post AND 25 posts.

    Thread Starter JonasVorwerk

    (@jonasvorwerk)

    That’s not what I’m searching for.
    The result I’m looking for is 25 last posts + all the posts form certain categories

    You’ll need 2 queries for that – 1 for the 25 latest posts and the second for all the posts from certain categories. You might want to have a look at multiple Loops for some examples.

    Thread Starter JonasVorwerk

    (@jonasvorwerk)

    This means duplicate posts which we don’t want..
    Thanks again!

    Not necessarily. You could loop through the objects returned from each query and weed out any duplicates before outputting the results to any page.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘multiple query_posts into one "AND"’ is closed to new replies.