Support » Plugins and Hacks » [Resolved] Result displayed multiple times.

[Resolved] Result displayed multiple times.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author meloniq


    Do you use some other plugins on your site? If so, which? Maybe it got into conflict with other plugin.

    Permarad is right – there is a bug.
    This happens when you have many postmetas attached to one post (even hidden with keys starting with “_”) . This plugin uses only one LEFT JOIN.

    Each postmeta key-value pair has it’s own row in postmeta table, so this plugin should generate a JOIN query for each pair, not just one.
    For example:

    $join .= "LEFT JOIN (SELECT post_id,meta_value FROM $wpdb->postmeta WHERE meta_key='_firstkey') meta1 ON $wpdb->posts.ID = meta1.post_id
    LEFT JOIN (SELECT post_id,meta_value FROM $wpdb->postmeta WHERE meta_key='_secondkey') meta2 ON $wpdb->posts.ID = meta2.post_id ...
    $where .= " OR ( meta_value LIKE '%{$wp->query_vars['s']}%' ) ";

    You should modify this plugin to use ONLY ONE user-defined postmeta key or build a large JOIN query for all existing postmeta keys.

    Hope this was helpful.

    Plugin Author meloniq


    Multiple JOIN’s are required only to query with AND, and not an OR

    For any sort of improvements (and even more rich description of plugin), PR welcome: https://github.com/meloniq/wp-admin-search-meta

    Is the way to fix this to use the code above? I only need to add the ability to search 1 item in the meta data. Thanks and let me know.

    I also have this bug, a fix would be great 🙂



    I was getting the same error. I was able to fix it by adding a DISTINCT filter


    add_filter('posts_distinct', array( __CLASS__, 'search_distinct') );

    to static function add()

    then the search_distinct() function to the class:

    static function search_distinct() {
    		return "DISTINCT";


    ALSO for anyone looking to have meta search on the front end, I commented out the following:

    		if ( ! is_admin() )
    			return false;
    		if ( 'edit.php' != $pagenow )
    			return false;

    davidsword’s fix works! Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Result displayed multiple times.’ is closed to new replies.