php – Looking for most performant way to execute several similar WP queries within shortcodes
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!
Leave an answer