WordPress will cache all terms for taxonomies attached to all post types in the query result set by default – well, so long as you haven’t set either cache_results
or update_post_term_cache
to false
(codex).
So calling get_the_terms
etc. within the loop will not hit the database. However, wp_get_object_terms
will hit the database as it by-passes WordPress’ object cache.
Related Posts:
- Why is my WP_Query not working when tax_query terms are an array?
- How to add terms to my tax_query based off of the current post
- Pass array of taxonomy terms to wp_query
- Formulate a url to show posts with both taxonomy terms
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- Function get_queried_object() return NULL in custom taxonomy
- Get authors by term id or slug
- Taxonomy order exception for specific term
- Get posts from multiple tax terms
- How to Order a list of taxonomies? orderby?
- How to add custom meta to ‘pre_get_terms’?
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- How to get posts by category and by choosing a taxonomy term?
- Can’t get term id for category archive
- How to make a post with certain taxonomy term display first before other post with only one query?
- How can I order a post query’s results based on the number of matching taxonomy terms?
- Only show tag with the same id as the post
- Save queried result into database
- taxquery taxonomy get terms
- How to show terms from another taxonomy
- How to define a custom hierarchy for terms?
- tax_query not working properly with get_posts
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- WP_Query vs get_posts
- Get posts from Network (Multisite)
- Sanitation needed for WP_Query or get_posts calls?
- Use of caller_ get_ posts
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- How-to exclude terms from the main query the most performant way?
- Meta Query with date and time on the same Day before given time
- Get posts with condition on comment meta value
- Move posts to top of WP_Query if in certain Taxonomy?
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- What should I use, get_posts or wp_query for less CPU load?
- Querying Multiple Custom Taxonomy Terms
- How to get post from all Blog Multisite to the Main Site?
- Get posts that matches specific terms of multiple custom taxonomies
- Order terms inside a select dropdown
- WP Query – Get WooCommerce Products with variation that is in stock
- Filter WordPress posts by between parameter
- How to Modify Taxonomy Archive Page with Search Parameter?
- Get array of current post term ID’s
- SELECT * FROM $wpdb->posts WHERE ID > 160
- Change default ordering of taxonomy terms – pre_get_terms
- WP_Query, tax_query and term_meta: How to?
- Is it possible to dynamically get queried term AND taxonomy?
- WP Query for variable taxonomies
- get_posts – get all posts by array of author
- get_posts() not working with multiple statuses
- Getting Taxonomy inside WP_Query Loop
- Complex WP_Query (two post types and multiple operators)
- Return only post(s) which have post_excerpt
- Remove category from query (show all posts in archive.php) pre_get_posts()
- WP_Query() and get_posts() can’t handle over a thousand posts?
- Display Featured Post by Categories and Avoid duplicated posts
- WP_Query tax query part of slug
- How to Union two different conditions in one WP_Query
- How do I exclude the lowest level terms in a taxonomy?
- Post loop for all taxonomy terms
- WP_Query post_parent parameter always returns children of current page
- get_posts output always same post
- get_posts() and global variables
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- Loop posts based on permalink term
- Check if a post has term inside loop
- Function using get_posts() with tax_query not working when called from functions.php
- Get posts by category name
- Search for pages with permalink
- Don’t repeat posts from children in parent taxonomy query
- Execute PHP function inside the admin area
- Show multiple tax_query from 2 or more post_type in a single code
- Deleting terms from the WordPress wp terms table
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- get_the_terms has strange result since version 6.0
- Strange behaviour of hierarchical taxonomy archive
- WP Query should show No Posts when tax_query $args taxonomies don’t have associated posts
- Populate select list with meta values from all posts of a Custom Post Type
- tax_query not working on custom post type
- Form checkbox value going to dynamic URL
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- get_posts return only first result
- WordPress – Form does not filter the results of taxonomies
- How to get meta key list efficiently?
- how to get wp_query posts only first letter of alphabet A?
- Show one post of each custom taxonomy
- How to break up output of posts for different terms on same page?
- Custom category page with taxonomy filters
- $product->ID in has_term() not working, but manually inputting the ID works, why?
- Ordering Posts by parent category, name ascending
- Use not custom fields in get_posts() meta_query?
- Mathematical operations on custom field values? (updated)
- How to get several fields from wp_query?
- get_posts works but new wp_query doesn’t
- Why WP_Query in functions.php is not working when get_posts works?
- Query specific number of posts for each post type in specific order
- get_posts shows current post, not defined posts with args
- Multiple Orderby is not working right
- How to retrieve _embed (etc) fields in get_posts custom query?