Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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(); ?>
            </div>
        <?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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.