• Resolved rreimche

    (@rreimche)


    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: http://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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter rreimche

    (@rreimche)

    I’ve just figured out that when value of the taxonomy $_GET variable equals custom taxonomy term slug value, the “countries=aaa” is transformed to “/countries/aaa”.

    Is there a way I can make so that it does not happen?

    I think u can try to change the names of the parameters in the url to be different from the names of the categories so use countryValue or countryName instead of countries . This way u can avoid this issue .

    Thread Starter rreimche

    (@rreimche)

    Thanks, Ahmed.

    Advices on the redirect problem would also be very helpful ,)

    Thread Starter rreimche

    (@rreimche)

    The problem was solved when I changed the names of the variables.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘A complex problem with displaying custom posts using parameters from $_GET’ is closed to new replies.