To limit the amount of results returned, add LIMIT 10
before the last closing "
, where 10 is the maximum amount of results you want to display. The resulting line 70 will then look like this:
$titles = $wpdb->get_results("SELECT post_title As name, ID as post_id, guid AS url, 1 cnt FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and post_date < NOW() and post_title LIKE '%".mysql_real_escape_string($term)."%' ORDER BY post_title LIMIT 7");
To roughly display posts of certain type before others, add post_type ASC,
or post_type DESC,
in between ORDER BY
and post_title
in the end. This displays the results grouped in alphabetical or reverse alphabetical order of the post type. To display eg. events before locations or pages before posts, use the first option (ASC), or to do it the other way around, the second.
Here’s an example line 70 with corrections in SQL capitalizations for improved readability and an unused query part (guid AS url) removed for performance:
$titles = $wpdb->get_results("SELECT post_title AS name, ID AS post_id, post_type, 1 cnt FROM ".$wpdb->prefix."posts t WHERE post_status='publish' AND post_date < NOW() AND post_title LIKE '%".mysql_real_escape_string($term)."%' ORDER BY post_type DESC,post_title LIMIT 10");
To add qTranslate support, change includes/tags.php line 72 from
$row_array['label'] = $word->name;
to
$row_array['label'] = __($word->name);
Despite displaying the titles in the site’s default language regardless of the user’s language setting, this is a considerable improvement over the previously shown <!–:en–>Post Name<!–:–><!–:fi–>Artikkelin nimi<!–:–> jumble.
I’ve added some filters to the plugin that should allow to handle all these situations. Can you try upgrading to 2.0.2 and let me know if that clears it up?
Filter Documentation
Closing this due to inactivity.
Tested with 2.0.4 and qTranslate support seems to be fine by default. If further needs arise, I’ll look into the filters and get back to this thread if appropriate.
Thanks a lot for your great work on the plugin!