show all post form specific post_type in wordpress

Hello all,
Now I am going to show how to get the post from a specific post type. Just follow the code –

$args = array( 'post_type' => 'product', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
	the_title();
	echo '<div>';
	the_content();
	echo '</div>';
endwhile;

Just put this information in your desire page and it will be post last 10 post. Be remember to change the ‘product’ name. It must be the name of your post type.

Thanks for reading…

Advertisements

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s