Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

portfolio Query

// WP_Query arguments
$args = array (
	'post_type'              => 'portfolio',
	'post_status'            => 'published',
	'order'                  => 'DESC',
	'orderby'                => 'date',
	'cache_results'          => true,
	'update_post_meta_cache' => true,
	'update_post_term_cache' => true,
);

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

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

// Restore original Post Data
wp_reset_postdata();