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]
- Custom query_var causes displaying posts archive on front page
- Why does get_the_time(‘F j’) return November 30 for all posts?
- Query by one meta_key and sort by another (possibly NULL value)
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- I have over 4000 posts, will querying some of them cause performance issues?
- Count user posts by user ID, Post type and Post status
- Can’t pass table to $wpdb->prepare
- How to get category link without a database query
- search through post-type attachments titles
- Date query year and month OR just year
- cron job to auto delete posts of a specific post type older than x days
- WP_query category__in not working, only pulls from first category
- Most effective use of DB querys
- mysql query paging
- Two differents queries in archive page
- How do I find if a page has a template?
- How to set back query var author_name after unset it?
- My SQL function to change user_name
- How select a specific query when setting offset?
- How to retrieve elements from another table in a SQL query?
- WordPress Loop: List All Posts by a Category & Subcategory
- Order query by post meta value
- Query Custom Post Type posts by Keyword/url slug
- how would I create a custom query to get all users, and a related post based on a postmeta field?
- Display posts with a start OR end date later than current date
- Form redirect with query vars to page
- Query to Get All Users from wp_users With NO matching user_id In wp_usermeta
- WordPress custom setting page – add flashing message
- Custom query AFTER rss fetch_feed not working
- Check return value of get_posts
- Multiple Category Query
- list all categories that have a certain word in title
- Passing parameters to a static front page
- wp_list_pages() refuses to output posts
- Can’t seem to do combined query AND sort?
- Custom query for custom post_type
- sort query results by newest
- How to reset usual $query on search page to push custom $wpdb query there?
- Order by meta value pro first then meta value free in my search function
- Why posts array is empty?
- Order posts by date, but also give priority for a specific term
- How to delete all posts, categories and tags from WordPress database
- Ideas how to search & replace post_content when string contains a newline?
- Query the WordPress database to get data together with replaced information
- $wpdb->prepare affecting the query?
- WordPress SQL search, how to handle SQL Injection?
- Query for Custom Post Type UI Does Not Loop All the Post
- Updating with $qpdb->query() always returns 0 rows affected
- Wrap/close ‘query’ for a first-letter ordered listing of posts
- How to manage a particular “order by” for get_search_query()?
- Query to view scheduled or draft post
- How to add a Variable to post query
- get products by custom date variable
- Sort a list of a CPT ( job) if a meta is empty
- Check if almost 10 year old – working code is up to date
- How to sort by two meta keys in admin area?
- wp query multiple values > display a specific value first
- PHP Fatal error: Uncaught Error: Call to a member function insert() on null
- Nested select statements not working
- Restore WordPress Backup Locally?
- Trouble migrating custom post types from non-wordpress cms
- “order” does not affect order of custom query
- Create a new post on a specified publish date via link?
- Exclude Posts from a Widget
- New custom post type entries are not sorted correctly in admin using pre_get_posts
- Query String for the WP_QUERY parameters
- $wpdb query for price in custom field value
- Multiple terms not working on taxonomy
- Sorting of coupons in the right way
- excludeCat function reverses order of blog posts
- Run search query again without pagination gives no results?
- Get multiple posts with some custom fields efficient
- WP_Query orderby meta key/value suddely stopped working
- Where can I find the SQL to get the most used information by wordpress database?
- WooCommerce Total # orders [closed]
- How to show sticky posts on all pages of the pagination, not just the first page?