Showing 1 post from featured category
This snippet shows one post from a category named “Featured”. Good for popping out extra important posts here and there on the website
// WP_Query arguments $args = array ( 'post_type' => 'post', 'category_name' => 'Featured', 'posts_per_page' => '1', 'orderby' => 'rand', ); // The Query $queryn = new WP_Query( $args ); // The Loop if ( $queryn->have_posts() ) { while ( $queryn->have_posts() ) { $queryn->the_post(); // do something } } else { // no posts found } // Restore original Post Data wp_reset_postdata();