Limiting the posts on the homepage to one taxonomy?

I’ve currently got this code on my homepage to display one random post from the Work section on my website – this is a custom post type utilising taxonomies – not blog posts:

<?php query_posts('post_type=work&posts_per_page=1&orderby=rand'); ?>

I want the items to be randomised so that a different one displays each time and I only want to display one item. However I want to know if it’s possible to limit it to just one taxonomy rather than all 5 that I have set up. I’d like to just show the work items listed within ‘Artists’

Read More

Is this possible?

—-EDIT————

I’ve tried:

<?php $query = new WP_Query( array( 'work' => 'artists', 'orderby' => 'rand', 'posts_per_page' => '1' ) ); ?>

but this doesn’t work – it brings back a link top ‘home’ instead. Not sure what I’m doing wrong.

Related posts

Leave a Reply

1 comment