0

I'm developing a website with a record for me query count. It has 720 Query for the main page. I want to reduce it.

The main page structure is like this:

  • ~10 Custom Taxonomy Term
  • Each Term has a query for name, slug, cover (from the term_meta table)
  • Each Term has 3 Custom Post Type
  • Each Post from these Custom Post Type query for ~4 Meta fields and thumbnail

I tried transient cache tech, but it didn't help me in the right measure.

Can I somehow reduce query amount by making a few queries to bring all data to arrays and manipulate with data using these arrays?

  • 1
    What is the code you're actually using to query all this stuff? Are you querying the 10 taxonomy terms separately? Or using get_terms() to get them all at once? What about the meta? Normally WordPress gets all meta values for each term or post in a single query too. And what about the posts within the terms? – Jacob Peattie Nov 8 '18 at 15:49
  • @JacobPeattie I get all terms with get_terms(). In foreach of get_terms() array I making get_term_meta() and get_option(). Next, for each term I'm making WP_Query() for each post type. For each post I'm making get_the_title(), get_the_id(), get_post_meta() and etc. I know that some data should be cached with the core, but 720 Query make this non-sense. 720 Queries showing the Query monitor plugin – okonik Nov 8 '18 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.