1:49 PM
1
A: Custom Post Type Query multiple Taxonomy Terms

birgireIf $input_terms is the input array of term slugs, then you should be able to use (if I understand the question correctly): $property = [ 'post_type' => 'properties', 'paged' => $paged, 'tax_query' => [ [ 'taxonomy' => 'features', ...

 
Hmmm... maybe I didn't put enough into the question to make it understandable - I have added to the question now. All I want to do is $_GET the URL; check if there is features in the search query and if there is return result depending on that query. However if there are 2 terms in the query only return the Properties with both terms
 
As a debug step, just use $input_terms = [ 'term_one', 'term_two' ] and make sure the $property array here above returns correct query results. What happens then? @CoderSte
 
So I've done a var_dump to make sure the query works and it seems to be correct. As for adding in the terms manually to $input_terms I have done that and I still get the result I am getting now with no change
 
I just tested this and it seems to work as expected on my vanilla install. I only get posts that are assigned to all terms in our $input_terms array. What does your SQL query look like? @CoderSte
 
By SQL Query I assume you mean the WP_Query for that page? If so here it is --> Pastebin Query
 
1:49 PM
The SQL of the query that is fed with the $property arguments. From your dump it looks like your tax_query is not an array of arrays. Try to copy the array structure I adjusted in my answer. @CoderSte
 
Yep I have just done that and sadly still no result :( - I appreciate your replies btw :)
Sure thing
 
I just tested this on my vanilla install and seems to work
i.e. I checked with $q = new WP_Query( $property );
and then peeked into print_r( $q->posts );
and checked echo $q->request;
 
Hmmm... Basically I am making a site for a client like a real estate so there's a lot of different queries for different things - I have a feeling that might be the problem. Question is can that cause problems?
I am using $wp_query = new WP_Query - I think that might be the problem
 
I thinks it better to take it in small steps
can you check it like how I tested it, just to find a common ground? ;-)
 
Yeah sure thing
Shall I put it into a paste bin
 
2:03 PM
yes, I guess it's easier to read that way
 
That's what I get when i result it your way :)
Basically I fixed it and then I haven't at the same time
 
I think I solved it - I'll explain how but I don't know if it will mean anything
 
ok great ;-)
 
I think before I was putting too many checks for different pages - I removed some of the checks and it just worked how I expected
I appreciated your help btw @birgire :) What do I do with the Bounty now?
 
2:22 PM
Where do you run this? Normally I would try pre_get_posts to modify the existing main query
no problem, looks like you solved it yourself ,so you could always add your own solution
 
I run it inside a file called template-properties
That's what is inside the who file
 
looks like you're running it as a secondary query
 
What you mean by that? I'm still pretty new to like Custom Post Type with queries. I used to just make standard custom themes for clients nothing this big at all
 
you could propably modify the main query with pre_get_posts, but just note that some page checks might be too early in there
 
Okay
So does it make a difference which one you use?
 
2:27 PM
but if this is on a page then that might be challanging
 
It is on a page it's on the page that list all the Properties the client uploads
 
I think @pietergoosen was working on it, how to modify the main query for a page to list other posts
 
Oh okay I'll speak to him about it
 
10
A: Using pre_get_posts on true pages and static front pages

Pieter GoosenI finally got it working, but not with the code in my question. I totally scrapped that whole idea and restarted going in a new direction. NOTE: If anyone are ever able to sort out the issues in my question, feel free to post an answer. Also, if you have any other solution, also feel free to po...

I think it's this one ;-) It's an interesting puzzle there he was trying to solve, but I just wanted to mention this approach ;-)
but good luck with the probject
and this classic regarding pagination for sub-quries:
96
A: How to fix pagination for custom loops?

Chip BennettThe Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom quer...

(overrding the main query object reminds of how the problematic query_posts work, so you might be aware of that too)
cheers
 
2:42 PM
Thank you for the links also thanks for the help again :)