I have a custom post type called "Milo-Books" and a category named "Featured" with ID of "100".
I want to run a query which pulls out on post from this category on the homepage, but randomly and I can't seem to get it to work. Could anybody help me out.
<?php $args = array( 'post_type' => 'milo-books', 'cat' => 100, 'show_posts' => 1, 'posts_per_page' => 1, 'orderby' => 'RAND' ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <h2>Featured Title</h2> <div class="featured-content-container"> </div><!--End Featured Content Container-->
It only displays one of my posts. In my custom post type I have set 3 posts up with the category FEATURED.
Have I missed something? Because If I change the posts_per_page to 3 it displays all three so they are recognised in that category. Just can't get them to display randomly.