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’
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.
Without knowing more details about your taxonomy schema, giving a precise answer will be difficult. However,
query_posts()
can be filtered by taxonomy, so you should easily be able to do what you need.