I have a custom post type called portfolio
and a taxonomy called locations
. In the taxonomy I have various terms, like paris, berlin, london
etc.
How can I get only the posts which are related to one term, e.g. paris
?
I am trying the following code, yet it gives me the ALL the posts of the taxonomy portfolio
and not just of one term:
$args = array(
'post_type' => 'portfolio',
'locations' => 'paris'
);
$my_query = new WP_Query( $args );
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
wp_reset_query();
locations
is slug for that taxonomy? Could you show taxonomy registration code?'taxonomy' => 'term_slug'
pattern is deprecated but should still work. Something else is wrong. Post debugging information please.'post_type' => 'portfolio'
but the question refers to "the posts of the taxonomy 'portfolio'".