php – Looking for most performant way to execute several similar WP queries within shortcodes

Question

I have a very data-driven website where each page contains several (5-10) shortcodes, each of which execute WP queries and display the results.

The queries are usually quite similar – I’ve added 3 examples of a var_dump of the WP query $args to this codeshare: https://codeshare.io/3AvRgv

I’m looking for a way to improve performance, and wonder if there’s a better way of doing this than having a new WP_query every time.

For example could I set some query parameters in a custom field, run the query when the page loads, save the array of post_ids to a variable, and then modify them to suit? Would that help?

Any ideas welcome!

0
Alex Smooth Websites 6 months 2022-02-22T14:45:46-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse