Ramdom Test Shortcode
Saca un test Random
// Add Shortcode function random_tests() { $args = array ( 'post_type' => array( 'cw_tests' ), 'post_status' => array( 'publish' ), 'nopaging' => true, 'posts_per_page' => '10', 'orderby' => 'rand', ); // The Query $query = new WP_Query( $args ); //var_dump($query); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); echo get_the_title(); } /* Restore original Post Data */ wp_reset_postdata(); } else { // no posts found echo "NO HAY TEST ?"; } } add_shortcode( 'test', 'random_tests' );