0

I would appreciate if someone could help me out with the following issue. Here is the thing. I created two select boxes so I could filter and display posts from a custom post type based on two values - custom taxonomy and custom meta value. Here is the code that unfortunately won't render my posts.

<?php
    $area = $_GET['area'];
    $menu = $_GET['menu'];

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
        'post_type' => 'restaurants',
        'posts_per_page' => 10,
        'paged' => $paged,
        'tax_query' => array(
            array(
                'taxonomy' => 'zones',
                'field' => 'slug',
                'terms' => explode(',', $area)
            )
        ),
        'meta_query' => array(
            array(
                'key' => 'zones',
                'value' => $menu
            )
        )
    );

    $the_query = new WP_Query( $args );
?>

I am developing a food online ordering system based on WordPress. My search form has two select boxes - Where do you live? and What do you want to eat?

So when a user selects Where do you live? value, the form should filter posts based on that value (i.e. custom taxonomy). Users of my site can also select a value from the other select box What do you want to eat? and the form should be able to update posts based on that as well.

Any hint or help would be greatly appreciated. Thanks a bunch!

-1

I've recently developed a plugin that can support the custom taxonomy element of this problem. The plugin creates select boxes for each of your custom taxonomy terms and throws the results onto a custom results page (of your choosing):

Advanced Custom Post Search

It currently doesn't support custom meta values if this is something you need, but may well include that in the next release.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.