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:

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!

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

Leave an answer