Most of my busiest pages have 5 different queries that look something like this:
new WP_Query(array( 'category_name' => "cat1", 'tag' => "tag1", 'posts_per_page' => -1, 'meta_key' => 'meta1', 'orderby' => 'meta_value', 'order' => 'ASC'))
My page is structured as such
section tag1 query posts marked with tag1 section tag2 query posts marked with tag2 section tag3 query posts marked with tag3 ...
Each query is differentiated only by the tag (tag1,tag2,tag3 etc.). Everything else is the same. So each post is from the same category, and that category of course is different on each separate page.
Question 1: Will this approach hurt my website speed/performance?
I get around 2000 visitors daily, and have 1core CPU/1GB RAM virtual hosting. I also use Varnish, W3 Total Cache and Cloudflare.
Question 2: Is there a way to combine these queries into a single one somehow? Run WP query once, and separate posts by the tag array. My coding skill is very limited, but seems this should be possible, and a more optimized approach.
I'm thinking something like this:
query posts within a given category if those posts have tag1 list all posts marked with tag1 if those posts have tag2 list all posts marked with tag2 if those posts have tag3 list all posts marked with tag3 ... end query
Any advice is appreciated.