Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thanks Renuplex! I’ve been googling all over for this. It surprises me that this functionality isn’t already built into a handy plugin like Search Unleashed.

    I got your code working on my site with a couple tweaks. I’m posting them here just in case anyone else is looking for this too.

    Thanks again,

    global $wp_query;
    $cats = $wp_query->get('cat');
    if($cats) {
        $sql .= " LEFT JOIN {$wpdb->prefix}term_relationships ON {$wpdb->posts}.ID = {$wpdb->prefix}term_relationships.object_id ";
        $sql .= " JOIN {$wpdb->prefix}term_taxonomy ON {$wpdb->prefix}term_relationships.term_taxonomy_id = {$wpdb->prefix}term_taxonomy.term_taxonomy_id";
    }
    $sql .= ' WHERE 1=1 ';
    if ($cats) $sql .= " AND {$wpdb->prefix}term_taxonomy.term_id IN ($cats) ";
Viewing 1 replies (of 1 total)