• Hello,

    I can’t solve my problem and can’t find any solution.
    I have a query and want only two catgories in it.
    “Neuigkeiten” & “Wettbewerbe”.

    I did an array, but it doesn’t work:

    <?php $query = new WP_Query(array('category_name' => array('Neuigkeiten','Wettbewerbe'), 'posts_per_page' => 4, )); while ($query->have_posts()): $query->the_post(); ?>

    This doesn’t work:

    <?php $query = new WP_Query(array('cat' => array('1','10'), 'posts_per_page' => 4, )); while ($query->have_posts()): $query->the_post(); ?>

    This doesn’t work:

    <?php $query = new WP_Query(array('category__in' => array('Neuigkeiten','Wettbewerbe'), 'posts_per_page' => 4, )); while ($query->have_posts()): $query->the_post(); ?>

    Do you have any ideas?

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You need to do category__in but instead of the category name you need to do the ids.

    Thread Starter razzgpe

    (@razzgpe)

    Thanks, but that shows also the other categories, even array(‘1′,’10’)

    <?php $query = new WP_Query(array('category__in ' => array('1','10'), 'posts_per_page' => 4, )); while ($query->have_posts()): $query->the_post(); ?>

    Perhaps I can do the other way, how can I exclude a category?
    This doesn’t work:

    <?php $query = new WP_Query(array( ‘cat ‘ => ‘-12’, ‘posts_per_page’ => 4, )); while ($query->have_posts()): $query->the_post(); ?>

    Thread Starter razzgpe

    (@razzgpe)

    Got it!

    It works without ”

    <?php $query = new WP_Query(array('category__in ' => array(1,10), 'posts_per_page' => 4, )); while ($query->have_posts()): $query->the_post(); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple categries doesn't work | array('category'=> ?!’ is closed to new replies.