wp_terms
, wp_term_taxonomy
, wp_term_relationships
and wp_term_meta
these 4 tables powers the WordPress taxonomy world. You’ll find the relation between post and term within these 3 tables wp_terms
, wp_term_taxonomy
, wp_term_relationships
. You have to start journey from wp_term_relationships
. If you wanna know more about DB schema https://codex.wordpress.org/Database_Description https://code.tutsplus.com/tutorials/understanding-and-working-with-data-in-wordpress–cms-20567
And query_posts()
is harmful and bad practice, it overrides the WordPress main query. Better you should use a custom query.
$query = new WP_Query( array(
'cat' => 2, // category id goes here
) );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
// do the whatever you wanna do inside the loop
endwhile;
endif;
Related Posts:
- WordPress Multisite – global categories
- Get posts from sites in Multisite?
- Can’t custom taxonomies have same terms (slugs) as categories?
- Using wp_category_checklist in a widget
- How to add the category ID to admin page
- Exclude one category from get_the_term_list
- WordPress remove separator from last item in wp_list_categories
- Filter categories using tags
- Need help adding custom field to category
- Show Post from parent category (custom taxonomy) ONLY!
- How to Include the Parent and Child Category in the Permalink if the Post is Added to Both
- How to display a list of categories
- Number of posts in page – set per category and exclude sidebar
- Create single.php for specific category by category id
- is_category in pre_get_posts results in php notices
- Use get_term_children to get the sub category of a parent category for the current post
- How to make all posts in a category “unsticky”?
- How do I get the total number of categories in a list of search results?
- How to stop wordpress from showing the selected category on top of others in the category selection?
- advanced custom field Show field in special categry page [closed]
- Creating archive pages for children categories
- “NOT ONLY IN” taxonomy query operator?
- Exclude Child Categories Using wp_list_categories
- How do I get a list of all categories that a given user has written blog posts for?
- Display the featured image from the last post
- Arrange posts by date in front page
- How to remove “Category : …”
- “Categories” on my front page [closed]
- Warning: sizeof (): Parameter must be an array or an object that implements Countable, On products pages
- How to loop only categories without posts (+ show category featured image with acf) [closed]
- Add “page-a” slug to category link if user visit category link from “page-a”
- create a page which displays a list of categories title+ short description?
- select parent category first then child
- Scheduling update post daily
- Retrieving category’s color with get_term_meta
- How to exclude children categories of parent category
- Assign category from custom field on post creation and update
- Sticky posts not working when a specific category is set
- Multiple category selection in post, shows less important category in breadcrumb
- I want to display the all the posts that are inside a certain subcategory
- Custom category URL rewriting
- Get Number of total Parent Categories for Custom Taxonomy
- Category template with pagination returns 404 on next pages
- Redirect single article permalink to paginated category page
- Exclude category by slug in pre_get_posts?
- add slug beside name in Admin Category Checklists
- How to show 5 posts from specific category on related page?
- List only categories i specify
- Author Page – List of categories plus number of posts in that category
- Exclude category from related post
- Post belonging to many categories
- How can you access category information from a theme?
- Filter WooCommerce archive pages by an additional category
- WP 4.7 in_category change?
- Display subcategories in dropdown
- Illegal string offset ‘taxonomy’ in
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Category Page Template – Can’t get category ID
- Are term_taxonomy_id and term_id the same? [duplicate]
- Filter Category Loop Dynamically
- SQL query to get posts from multiple categories but not in a category
- Can each user have only access to a private area (his own categories and posts)?
- Shortcode to display all the post from a category in a page
- WP Category Meta plugin fix? [closed]
- WP SQL Categories Export and Import
- How to display WooCommerce category image in my category page banner as a background?
- Why are my newly added categories not showing up when creating a post?
- Order wp_dropdown_categories by ASC or DESC
- add woocommerce archive description if exist
- Can’t display posts by filtering categories using isotope.js
- Get a list of categories, separated by / to display inside the for custom metatags
- Is there a reason to put a product in both the Child and Parent Categories?
- Get_term_meta() always returns false
- Get only children category name
- Displaying only selected categories
- No results found for second level category
- get_the_category vs wp_get_post_categories
- How to get get_categories()’s ‘hide_empty’ argument to work with global year var in the archive template?
- Getting a sub category based on a category name
- How to display only sticky posts on category pages?
- I have many different products on my website how can I get them to display under specific categories?
- Help with SQL query, how to add taxonomie terms with value stored in options?
- /blog/ permalink prefix causes category pages to 404
- Categories in media library
- WordPress Shop and restricting products and categories for some users/groups
- Pass list of categories to JS
- WP url to get rss with full text of post
- Display Referring Category on single post?
- Conditional statements based on custom meta value in category archives
- Paginating a list of all posts collected by category titles
- Display deepest post category, when post have multiple categories
- Paginate WordPress Category Pages
- Get a list of post titles and links from yootheme master theme
- Customize category query in widget
- Page permalink rewrite
- Broken category styling
- Excluding cateory not working on my site. how to solve this? [closed]
- Get all first images of posts in same category
- Woocommerce Force the category choice before creating new product? [duplicate]
- Replace category titles inside RSS feed