Timeline for Can i merge 2 new WP_Query($variable) 's?
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 26, 2020 at 10:03 | comment | added | Loosie94 |
In addition, you'll also need to update the "found_posts", like: $wp_query->found_posts = $promotor->found_posts + $other->found_posts;
|
|
Jun 3, 2020 at 23:32 | comment | added | armadadrive |
If you end up creating a new array and removing duplicates using something like array_unique() , you should be able to populate $wp_query->post_count with count($wp_query->posts)
|
|
Oct 28, 2019 at 21:46 | comment | added | Boycott A.I. | @harvey Sorry, can't find any code to do with that. (It was a few years back.) Your best bet might be to post a new question. Good luck. :-) | |
Oct 28, 2019 at 18:25 | comment | added | harvey | @ban-geoengineering Have you ever figured this out? I am stuck with this as well. | |
May 8, 2016 at 21:48 | comment | added | Craig Harshbarger | Thanks for this. Had a problematic meta_query using an OR relation. Split it up using this technique and went from 41s to 0.01s. | |
Nov 5, 2015 at 8:02 | comment | added | roshan | How can I remove duplicates from this merged array? | |
Jan 3, 2014 at 15:32 | comment | added | guidod | You should add a different question since it's a different answer, but you can use this same code but only the query2 parts, modifying the ->posts and ->post_count parts of the $wp_query object to have the sum of the original query that pre_get_posts gives you and the second query you want to append. | |
Dec 30, 2013 at 22:14 | comment | added | Boycott A.I. | This looks good, but I am looking for a solution that can be used with the pre_get_posts hook - i.e., I need to modify an existing WP_Query object. I have tried using '$wp_query->init();' instead of '$wp_query = new WP_Query();', but that seems to mess things up. Any suggestions? | |
Nov 13, 2013 at 21:58 | history | edited | guidod | CC BY-SA 3.0 |
I mistakenly wrote found_posts instead of post_count
|
Nov 13, 2013 at 20:44 | history | answered | guidod | CC BY-SA 3.0 |