To check if the query itself is slow or anything else slows it down, try running your query directly in the database, and have a look at how long it takes there.
<?php echo $GLOBALS['wp_query']->request; ?>
This shows you the latest Query that WordPress ran in your database.
If the query is really slow in the database, try caching the results, running this specific quer only once every hour or so. I usually do this with menus – but it works with anything. Using transients to save the output HTML.
I wrote about this technique here.
If you need different output for different taxonomies, try adding the TermID in the name of the transient.
You could delete the transients either on ‘update_post’ or let them expire after a certain time.
Related Posts:
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- What is the most efficient way of implementing a favorite post system?
- Advanced Custom Fields – Query Efficiency
- Does meta_query work within get_posts array?
- Mysql / WordPress killing my server with 80k users [closed]
- How to show more than 5 posts?
- How to optimize my query filtering out unwanted data?
- Remove posts from query for events whose start date has passed
- get_posts() loop returns the same the_title() for each post
- List all posts from past week grouped by sub-category
- Order posts by custom field DATE value
- Why a URL with a query is always slower than that without a query?
- How do I see the mysql query generated by get_posts( $args )?
- Create Indexes for Slow Queries
- get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)
- pre saved posts query from db options table
- wp_posts query slowing down my website
- Re-sort get_posts query results
- Can I include get_posts in this array?
- Improve performance of slow query
- How can I get posts by 2 meta keys, prioritising one of them?
- Category_in return empty
- Performance of wp_get_attachment_image_srcset() and wp_get_attachment_image_url()
- Sort order in get_posts [closed]
- When should you use WP_Query vs query_posts() vs get_posts()?
- How to display SQL query that ran in query?
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- Get the ID of the latest post
- How to get comments by post ID?
- WP_Query vs get_posts
- Differences between wpdb->get_results() and wpdb->query()
- Is there a way of increasing the speed of this query?
- Get all image from single page using this query
- How can I query all users who registered today?
- Get Terms by IDs with IDs order
- Reversing the order of posts AFTER the query is performed
- what are the numbers between curly brackets in search query
- simple sql query on wp_postmeta very slow
- Using WordPress public query variables
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- Differences Between WP_Query() and get_posts() for Querying Posts?
- How to get link and title of next and previous post on single page
- Create pagination and order according to alphabet
- wpdb get posts by taxonomy SQL
- How to List Events by Year and Month Using Advanced Custom Fields?
- What is the most efficient way of querying posts based on visits and date for current day?
- How to organize and cache additional data associated with terms?
- wordpress query – orderby child post date
- How many WordPress SQL Queries per page?
- How to display Section for certain time
- Add multiple value to a query variable in WordPress
- Search custom post type by meta data
- Custom query_var causes displaying posts archive on front page
- How to know if get_posts() failed?
- Slow wp_enqueue_media()
- Multipart/formatted MySQL query problem
- Remove [gallery] shortcode altogether
- Compare two numeric custom fields
- wp_dropdown_categories with multiple select
- Why does get_the_time(‘F j’) return November 30 for all posts?
- Get posts by meta data OR title
- Disable slow media queries?
- Query by one meta_key and sort by another (possibly NULL value)
- How to tune search argument in WP_Query to show only exactly the same results?
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- query multiple taxonomy and show post count
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- Query & Sort Comments by custom comment meta
- How to get my loop to pull posts into three columns
- I have over 4000 posts, will querying some of them cause performance issues?
- How to display lastest post date in the homepage?
- Custom $wpdb Query for Custom Post Type by Category
- Limit number of pages in pagination
- Get a user’s most recent post title
- Categories and products in random order
- add_query_arg() XSS Vulnerability
- Count user posts by user ID, Post type and Post status
- Can’t pass table to $wpdb->prepare
- Query set using tax_query with relation ‘OR’ modifies category object?
- $query->query_var[‘post_type’] not set for pages
- is_archive() doesn’t work on public query var archive pages?
- How to extract all ID variables from a query string?
- When add_query_arg() is necessary?
- Different Main Navigation per category
- How to get category link without a database query
- Insert html after certain amount of posts?
- wp remove query
- Show recent products first but “sold out last” in query
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- Can not switch the queried post in pre_get_posts hook
- Filter query posts by the count of metas for a meta key
- How to tell if $query_var isset?
- Show All Posts Insert Edit Link
- $wpdb->get_var not returning a result
- get_the_foo() in the loop – does it perform another query?