The only real difference in the 2 queries appears to be the post_type. I’ve absolutely no idea if this will work but have you tried using 'post_type' => array('post','dd_tla'),
?
I have indeed tried that, but doesn’t work. I suspect because I need to be very specific with the cats/tags/etc, so it just ignores the posts of that type because they don’t comply to the criteria, hence the need to merge the two seperate queries.
I am looking at custom queries, but not really savvy enough on SQL to pull it off!
Is there any specific need to just run a single query? Or could you run your two queries as they are and then just merge the results into a single array?
I could do that, wouldn’t effect the page, but don’t know how – thought you could only run one query per page!
You can run as many as you like as far as I know – although you may get performance issues if you run a dozen. 🙂
I’ve just been working on a template that merges the results of two queries. I want x posts on the page, so first I query on sticky posts. If the number returned in the array (y) is less than x, I run a second query for x-y posts in a specific category minus any stickies, merge the two arrays and output the results. That way I always get x posts on the page and the user can control which posts and their rough order.
I’ve been using get_posts for the 2 queries. If you’re using query_posts, you might want to use wp_reset_query()
after each query_post to stop them impacting on any other Loops further down the page. But, other than that, it should work.
Ok, I’m giving this a bash right now.
One problem I’m not sure how to overcome though is that through having to combine two arrays that have been generated through get_posts()
(don’t think you can put query_posts()
in to an array, but please correct me if I am wrong) I have all my posts displayed on a single page, rather that only 10 a page as I could through the post_per_page
argument for query_posts()
. Any ideas how to solve this at all?
Thanks.
An array_merge has worked for me thus far. Not 100% sure if that is THE correct way to do it though.
Found another way around this now as could not get anywhere with what I originally wanted to do!
Thanks for the advice.