Created
September 23, 2014 14:36
-
-
Save shazahm1/84e8dce8c4eb1ede3512 to your computer and use it in GitHub Desktop.
Search Category Desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function cn_search_category_description($scored, $terms) { | |
global $wpdb; | |
$select = array(); | |
$from = array(); | |
$joun = array(); | |
$where = array(); | |
$select[] = 'entry_id'; | |
$from[] = CN_TERM_RELATIONSHIP_TABLE . ' tr'; | |
$join[] = CN_TERM_TAXONOMY_TABLE . ' tt ON tr.term_taxonomy_id = tt.term_taxonomy_id '; | |
$where[] = $wpdb->prepare('MATCH (description) AGAINST (%s IN BOOLEAN MODE)', $terms); | |
$sql = "SELECT " . implode( ',', $select ) . " FROM " . implode( ',', $from ) . " JOIN " . implode( ',', $join ) . " WHERE " . implode( ' AND ', $where ); | |
$ids = $wpdb->get_results( $sql, ARRAY_A ); | |
if ( ! empty( $ids ) ) $scored = array_merge( $scored, $ids ); | |
return $scored; | |
} | |
add_action('cn_search_scored_results', 'cn_search_category_description', 1, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment