How can I check two category_name values in the following query_post?
<?php query_posts('category_name=recent-work&posts_per_page=1');
if (have_posts()) : while (have_posts()) : the_post(); ?>
So that it reads something like this:
<?php query_posts('category_name=recent-work&&category_name=plumbing&posts_per_page=1');
if (have_posts()) : while (have_posts()) : the_post(); ?>
Many thanks.
EDIT:
<?php
$querySimilarWork = new WP_Query( array(
'tax_query' => array(
array(
'taxonomy' => 'categories',
'field' => 'slug',
'terms' => array( 'recent-work', 'plumbing' )
)
),
'posts_per_page' => 4
);
?>
EDIT:
If I now query this WP_query, it doesn’t return anything?
<?php while ($querySimilarWork->have_posts()) : $querySimilarWork->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
Don’t use
query_posts
. UseWP_Query
, and use it’stax_query
.