WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to accomplish something like this:

        <?php $custom_posts = new WP_Query(); ?>
        <?php $custom_posts->query('category_name=Business OR category_name=Technology OR category_name= Lifestyle'); ?>
        <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
            <div class="content-block-14">
                <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                <?php the_content(); ?>
        <?php endwhile; ?>

So that if the post belongs to only one of those categories it should be listed in that loop.

Any suggestions?

share|improve this question
why don't you try is_category(); – ntechi Jul 6 '11 at 7:18
up vote 1 down vote accepted

If you have the category ID you can use the category__in parameter eg:

<?php $custom_posts->query(array('category__in' =>array(1,2,3))); ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.