daknetworks.com

You are here: Blog WordPress Multiple Category Search

WordPress Multiple Category Search

Where do I start? Forgot my rant on how the world operates and has chosen WordPress over so many other better CMS's...

Have an array in an URL like this: &foo=1,2,3,4

Take that array and search for all of them.

The OPERATOR => IN, is the includes.

Basically, we are trying to get a %like% sql statement.


        if (isset($_GET['area']) && !empty($_GET['area']) && $_GET['area'] != 'all') {
            $propareaArray = explode(",", $_GET["area"]);
            $tax_query[] = array(
                'taxonomy' => 'property_area',
                'field' => 'slug',
                //'terms' => $_GET['area'],
                //'terms' => array($proparea[0],$proparea[1]),
                'terms' => array_values($propareaArray),
                'operator' => 'IN'
            );
        }

 

NOTES:

Don't ask me why 'EXISTS' doesn't work. I think it should. If it did, I wouldn't have to go through this.

Contact Dak Networks

We are not taking on new clients at this time.