A complex problem with displaying custom posts using parameters from $_GET
-
Hi, all.
At first, the database structure. I have:
A custom post type “tours”, custom taxonomies “tourcategories”, “countries” and I also have custom fields and the two I need in the script I’ll describe is “price” and “date_meta”.
Using a script (javascript), user “constructs” a query (i.e. user clicks buttons and a value for every mentiond variables is set for the query) and “launches the search” (i.e. user is redirected to an address like this: https://mysite.com/?post_type=tours&price=10000&countries=5&date_meta=3&tourcategories=1 ).
Then a script that is hardcoded into index.php processes the $_GET variables, constructs the query, processes it and displays the posts. In fact, the index.php is divided into two scenarios; one for the case when there IS $_GET and one where there’s no $_GET.
The problem for now is that when I add one of my custom taxonomies to the address (for example, I add tourcategories=1 or countries=5), the URL transforms and I get something rather different than what I need:
“?post_type=tours&price=10000&date_meta=3&countries=5&tourcategories=2” brings me to 404.php
I could process $_GET in 404.php, but it seems for me not a right way.
Sometimes (I couldn’t yet figure out when) the “countries=anything” is transformed (by rewrite rules?) into “/countries/anything/” that is inserted before “?”.
Well, seems that I’m a bit stuck ??
In the Codex I’ve read that in order to commence custom queries one should perform such edits like adding variable to a list of those that wordpress recognizes, but that, as I’ve thought, is fair if one uses standard wordpress Loop and as for I use query_posts($args) I could do otherwise.
Please point me somebody into the right direction.
- The topic ‘A complex problem with displaying custom posts using parameters from $_GET’ is closed to new replies.