Home » WordPress » Display Custom Post Types using WP_Query

Display Custom Post Types using WP_Query

Now I show you how to display Custom Post Types using WP_Query. In WordPress, we can display the Custom Post Type posts in various ways, but using WP_Query gives a benefit to customize your entire post listing view. With the help of WP_Query arguments, you can list the posts by post type, post status, post order, posts per page, etc. As you like you imagined as you customize and get the view of the post listing.

Create a Custom Post Type in WordPress

Before you start you required to create the Custom Post Type either by plugin or without a plugin. For that here you have an article, If you already created ignore this.

Display Custom Post Type With Created Custom Template

Once you created or duplicated a archive.php with the name of a archive-resources.php by using FTP, cPanel, or WP File Manager then open the archive-resources.php in your theme folder and use the WP_Query in the template. If you need more clarification about creating or duplicating archive.php check this article.

Use the below code in archive-resources.php to display the Custom Post Type posts.

Note: Here we displayed only for the particular custom post type resources. Now you need to replace it with your custom post type name which you created.

Output:

output for custom post type wp_query

Conclusion:
I hope this article will help you to use WP_Query in the best way and if you have any doubts about this topic let me know in the comment box. If you like this article share it with your friends.

Was this article helpful?

Yes No
×

How can we improve it?

×

We appreciate your helpul feedback!

Your answer will be used to improve our content. The more feedback you give us, the better our pages can be.

Follow us on social media:

Facebook Pinterest

Mraj

Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top