Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Your taxonomy code looks good. There are many parameters, whether those particular parameters are appropriate for your need, it’s hard to say. But overall it looks good and it will work on some level.

    To find matching posts by assigned taxonomy terms, we use the WP_Query class. In particular you will want to specify a post_type parameter and a tax_query parameter (sections 5.4 and 5.8). The tax_query parameter involves nested arrays. It’s a little difficult to grasp the concept at first, but the nested arrays allow for very complex taxonomy term criteria, so it’s perfect for your need. If you study the examples, you should be able to figure it out. If not, ask here and someone will try to clarify.

    Note that the taxonomy parameter does not care about hierarchical relations between terms, all that matters is if assigned terms match the criteria you specify. For example, it doesn’t care that model mini is a child of make Ford or make BMW, only that the mini term is assigned to the cars post. If Ford is also required, that would be a separate criteria. Still part of tax_query, but a different inner array.

    Thread Starter glauco486

    (@glauco486)

    @bcworkz,
    Tanks, works. i used $get_[‘make’]; and model… and IFs.

    Now i need in search box:
    select make select models
    [make] [models]
    bmw a20 a30 ..
    ford ka mini ..

    on click in make , auto update models from make.
    any examples ?

    Moderator bcworkz

    (@bcworkz)

    You could try a search: https://www.google.com/search?q=cascading+dropdown+ajax+wordpress

    Ajax in WP has a few quirks. If any example fails to send Ajax through admin-ajax.php, it’s Doing It Wrong™ 🙂 More on Ajax, but not dropdowns, can be found in the Plugin Handbook.

    If you’re new to Ajax, I suggest getting some very basic data correctly making a round trip before getting fancy with actual queries. Incrementally build upon what you’ve gotten to work so far. Trying to code the entire thing from the start generally results in too many errors to know what’s going on in my experience. YMMV.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘post_type + taxonomy + search’ is closed to new replies.