How To Get Posts Or Custom Posts By Query In Wordpress?


Yes, Simplest and easy way to get the post and our created custom post type by wp query.

Just copy and paste below code into your file where you want to show /display your posts or custom posts.

	 'orderby' => ASC,
	 'post_type' => 'albums', // this is our custom post type  

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

if ( $the_query->have_posts() ) {
	while ( $the_query->have_posts() ) {

		the_title(); // it will display the titles of all posts that are added. 
                the_content(); // it will display the content of all posts that are added.
} else {
	// no posts found
endwhile; wp_reset_postdata();

Thats's it

We are accepting blogs for Tech News Write For Us category.