Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Post by category

// WP_Query arguments
$args = array (
	'category_name'          => 'homepage',
);

// The Query
$home_query = new WP_Query( $args );

// The Loop
if ( $home_query->have_posts() ) {
	while ( $home_query->have_posts() ) {
		$home_query->the_post();
		// do something
	}
} else {
	// no posts found
}

// Restore original Post Data
wp_reset_postdata();