Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Paste into your search page.
- if (array_key_exists('s', $_REQUEST) && $_REQUEST['s']) {
- global $wpdb;
- $s = array_map(function($e) { return esc_sql($e); },
- explode(' ', urldecode($_REQUEST['s']))
- );
- $s = '(description LIKE "%'.implode('%" OR description LIKE "%', $s).'%")';
- $res = $wpdb->get_results(sprintf('SELECT * FROM %s a INNER JOIN %s b ON b.term_id = a.term_id
- WHERE %s GROUP BY a.term_id',
- $wpdb->term_taxonomy,
- $wpdb->terms,
- $s
- ));
- if ($res) {
- echo '<pre>'.var_export($res,true).'</pre>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement