@ ssnoomann
re: One of the things they do is Yoga. Their business name and other searchable fields do not contain the word ‘yoga’. So, when I search for yoga their business does not show up in the results. They are categorized under ‘Yoga & Meditation’ but the search function does not search categories. Is there a way around this?
Install the Code Snippets plugin create a new snippet with the following code.
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);
Save and Activate the snippet. Now searches will include the category field description.
re: Can the search function not reset itself to the root URL rather than just searching from however many levels down you may already be in the directory?
Hmmm… that is a bug. The search should be from the permalink root and not the category tree. I’ll look into and ensure that is addressed in the next update.