• Resolved bbirchmeier

    (@bbirchmeier)


    Hello,

    I am using WooCommerce on my site, and I only have SKU checked for WooCommerce Search. After searching a specific SKU, my search still has about 80 items display that do not use that SKU. Each of those items have that sku in a table that is displayed in the post_content section of that product’s page.

    I don’t have any plugins active that effect search.

    Please let me know if you have an ideas, thanks.

    https://wordpress.org/plugins/search-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi bbirchmeier,

    Thank you for contacting us!

    If I understand you correctly, you have the SKU in post_content in your products. If so, your product will appear in search results regardless of using this plugin.

    This is because WordPress searches in post_title and post_content by default. And if you have SKU in content or title, products will appear in search results anyway.

    If I misunderstood you, can you provide more details please?

    Thanks!

    Thread Starter bbirchmeier

    (@bbirchmeier)

    Hello!

    Could you point me in the direction where I may change search so it doesn’t look through post_content?

    Thank you very much!

    Hi,

    This plugin does not provide such options.

    To do this you need custom code, something like this:

    // some function that modifies the query
    function modify_search ( $where ) {
    
    	global $wpdb;
    
    	if( !is_admin() ) { // here should be additional checks
    
    		return $where = ""; // custom sql here
    
    	}
    
    	return $where;
    
    }
    
    // attach your function to the posts_where filter
    add_filter( 'posts_where' , 'modify_search' );

    In ‘return $where = “”‘ expression you should specify your SQL query. It can be various depending on your project features.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin doesn't seem to be working’ is closed to new replies.