How to fetch post id using the term id in WordPress

For the different type of operation, we need to filter the default loop in WordPress. Sometimes we need to get post ID from a specific term ID(tag, category). In this tutorial, I will show you how to get post ID by category/tag ID.

The useful function is given in bellow-

Here we have used

global object of wpdb class which contains a set of functions used to interact with a database.
In fact, using

you can get IDs of posts by any parameter — category name, publish date, number of comments, even by comment author email etc.
🙂 happy coding!

Leave a Reply

Close Menu