Is there a plugin available? Or suggestions on how to achieve re-ordering automatically and randomly custom post type?

  • 2
    As for the earlier: Theme- or plugin-recommendations are off-topic here. As for the latter: Please include some code, such as your current loop for the CPT. What have you tried so far? Commented Jun 30, 2013 at 11:41

2 Answers 2


Or the pre_get_posts approach for the CPT archive.... which is more efficient since you don't query twice.

function wpa104766_randomize_cpt( $query ) {
    if ( is_admin() || ! $query->is_main_query() )

    if ( is_post_type_archive( 'movie' ) ) {
        // Display custom post type called 'movie' in random order
        set_query_var( 'orderby', 'rand' );
add_action( 'pre_get_posts', 'wpa104766_randomize_cpt' );

I guess it's just about displaying randomly cpt with a query :

$args = array(
       'post_type' => 'your_custom_post_type', 
       'orderby' => 'rand'

 $query = new WP_Query($args); 
 if($query->have_posts()) : while($query->have_posts()) : $query->the_post();
// html markup here
<?php endwhile;
endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.