How to hide or show items in search results

Super Speedy Search is incredibly fast at finding what your customers are looking for. But maybe you want to hide some things from search results?

Hiding Products from Search Results using Hidden

If you are on our default config, there will be a setting configured to replace the slow catalog/search visibility with our own technique. In this case, if you wish to hide a specific product from your search results, you can choose to HIDE the product.

Hiding Products from Search Results using ‘Shop Only’

If you try switching a product to ‘Shop Only’ you’ll find that it still appears in the search results. We are aware of this issue and will be releasing a fix soon.

In the meantime, you can add the following to your wp-config.php file to get Shop Only working as expected (to hide items from search results).

    define( 'SSS_FAST_VISIBILITY_CHECK', false );

Once you have that option above altered, the ‘Shop Only’ setting will work to hide items from the search results.

Hiding Products from Search Results using PHP filters

Maybe you wish to exclude entire categories of products from your search results? Or maybe you have some other need to remove items.

Since we have our own custom-rolled ultra fast ajax, you cannot just add this code into the functions.php file – functions.php is only loaded when the theme is loaded and we avoid that in our ultra fast ajax.

Instead, to add programmatic filters, add a file called sss-filters.php to the top level of your theme folder. SSS will then include this file if it exists for both full page results and our ultra fast ajax.

<?php
add_filter('sss_posts_search_where', 'my_posts_search_where', 10, 2);
function my_posts_search_where($where, $wp_query) {
global $wpdb;
$where .= " AND wp_posts.ID NOT IN (SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id = 1)"; // exclude posts with term_taxonomy_id 1 (e.g. to exclude categories)
$where .= " AND wp_posts.ID NOT IN (3253138)";
return $where;
}

Be the first to comment and we'll reply right away.

Leave a reply

Super Speedy Plugins
Logo