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?
- How to use the_posts_navigation for wp_query and get_posts?
- tax_query in get_posts() not working?
- Show posts without term
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- How to order by post_status?
- Search custom taxonomy term by name
- Get Recent Posts by Date in Multisite
- Is it possible to select against a post’s parent’s fields with WP_Query?
- Get list of posts which have at least one term from a custom taxonomy with WP_Query
- Get posts by meta data OR title
- Get_post() with meta_key when compare is a date
- Function to check if author has posted within the last x days
- List taxonomy terms plus their latest post ordered by post date
- WP Query post meta value
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Filter and list posts of a custom taxonomy
- List all custom post type posts from a given category?
- Trying to check and see if a post has a featured image outside of the main loop
- Filtering posts by custom field value not working
- Get posts for last working week in WP_Query
- Create a sitemap without a plugin – get parent pages only?
- get_posts – find out if querystring was crap and fallback is used
- Creating query to show which editor (classic or block) was last used to edit a post/page
- WordPress Related Post by tags in Single.php
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Advanced Taxonomy Queries WordPress
- add active class based on permalink and url
- Weird orderby => post__in issue
- WP Query Args – Title or Taxonomy Value
- How to order posts by title after they have already been sorted by category
- Why does get_posts only show results for Admins or logged-out users?
- get_post_meta slowing down my page load (in a plugin)
- How to show more post at a given category?
- Get posts by list of post IDs ordered by those IDs?
- Reset WordPress Post Query to default
- Filter Custom Taxonomy Posts
- meta_query: check if number exists
- Using custom taxonomies in a query
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- “paged” in WP_Query returns 0 posts
- Specify strict ‘order by’ in WordPress query
- get_the_terms – but only show 4 Posts
- Count posts per taxonomy else change taxonomy if less than x number
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- WP_Query to output chosen term and posts with no term assigned
- Check if searched number is within the post meta value
- How to echo woocommerce category name
- WP_User_Query and user posts
- WP Query – filtering terms with regex
- relation OR instead of AND – Filtered term ID’s in loop
- Avoid WP_Query’s duplicate posts with taxonomies
- Why always one post missing
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- Why my query is not “Main_query”?
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- Facing problem with tax_query results
- How to display Woocommerce products list by tag
- get_posts query caching?
- Get posts with any value in attribute
- Taxonomy Terms That Don’t Exist Display Results
- Slow query when selecting with large meta query or post__in
- Custom taxonomy and query multi conditions
- WP Query with sticky posts and tax_query
- Empty ‘terms’ in ‘tax_query’ returns an empty array
- Both WP_Query and get_posts returning 1 post
- Get the tax term in which is a post via wp_query
- Displaying Results From Custom Taxonomy Query
- Weird query with get_posts and WP_Query
- orderby and order filter in get_posts or WP_query function in wordpress not working
- Query custom post types by meta field in a term from custom taxonomy
- query only direct child and sub-terms of a current term archive
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Empty query on Custom Post Type, using WP_Query or get_posts
- A Depth Like Parameter For “get_posts”
- When to use WP_query(), query_posts() and pre_get_posts
- Equivalent of url_to_postid() for non-post URLs?