Fixing Search in Ultimate Tag Warrior WordPress Plugin

Fixing Search in Ultimate Tag Warrior WordPress Plugin

I have two fixes for users who are having trouble getting wordpress search to work correctly with the Ultimate Tag Warrior Plugin:

1. Change the join criteria for wp_tags and wp_post2tag:

On or about Line 883

$join .= " LEFT JOIN $tablepost2tag p2t on $wpdb->posts.ID = p2t.post_id LEFT JOIN $tabletags on p2t.tag_id = $tabletags.tag_id ";

This change will stop the sql query from filtering out any posts from search that have no tags assigned.

2. The wordpress search input is not being cleansed correctly and without the fix below the users search input will not match the tags.

Add the following to the ultimate_search_where function

function ultimate_search_where($where)
…<snip>
$searchInput = $wp_query->query_vars[‘s’];
$searchInput = str_replace(‘ ‘, ‘-‘, $searchInput);
$searchInput = str_replace(‘"’, , $searchInput);
$searchInput = str_replace("’", , $searchInput);
$where .= " OR $tabletags.tag like ‘%" . $searchInput . "%’";
 

This fix above structures the user input to ensure proper matches against tags.

Hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *