Taxonomy in loop
-
Hi there,
So I have created 2 new taxonomies in my fuctions.php :
// Adding Taxonomy !
function create_my_taxonomies() {
register_taxonomy(‘locations’, ‘post’, array(
‘hierarchical’ => true, ‘label’ => ‘Locations’,
‘query_var’ => true, ‘rewrite’ => true));register_taxonomy(‘activities’, ‘post’, array(
‘hierarchical’ => true, ‘label’ => ‘Activities’, ‘query_var’ => true,
‘rewrite’ => true));
}add_action(‘init’, ‘create_my_taxonomies’, 0);
?>
And now I try to use them in my loop like that –
<?php query_posts(array(‘locations’ => ‘vejer’)); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h2>
“
rel = “bookmark” title = “
<?php the_title_attribute(); ?>”
alt = “
<?php the_title_attribute(); ?>”
>
<?php the_title(); ?>
</h2>
<?php endwhile; ?>
<?php else : ?>
<h2>Sorry nothing Found</h2>
<?php endif; ?>This works perfect, but I have a simpler case that i can’t seem to sort out – what if I want to display all the posts that have taxonomy ‘locations’ ?
Thanks,
Amit
The topic ‘Taxonomy in loop’ is closed to new replies.