WordPress: Query Loop and Its Usage

Kartik Jain
2 min readMar 18, 2022

Hello Folks, Are you new to WordPress and you are trying to Create New Page Template on your own and you want to show all the posts, pages or custom post types in a loop? This is what I am going to write about its proper use.

By default WordPress allows you to categorize your content. This functionality is extremely powerful and allows you to have full control of your content. Using this WordPress Code Snippet will allow you to find all posts (custom or pages) that are in the same category. This will allow you to build recommended reading sections, customize your archive pages, or whatever other functionality you can come up with when grouped by category.

Build the Query with WP Query: Add this query to the template you wish to load posts by category:

In between the Query, You can see <h3>. At that Place, You can place your custom HTML Code Like How you are going to Show the Posts to the user.

Now there is one more case about Pagination in Post Page, If you have more number of posts, then you need to paginate it like 9 Posts Per Page.

For that As Well I Have Prepared A Code. You just need to Copy and Paste the Given Code and Style the Pagination as You want.

That’s All Folks. Hope you liked the Basic Step of WordPress. Don’t forget to comment About the problem you are facing.

--

--