Hiding A SINGLE collection item from site search

I want to exclude a SINGLE collection item from search. Please advise on how I can do this.


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

I’m afraid that’s not possible.

Go to CMS collection pages > site search setting. Enable the option “exclude these from site search pages” by mentioning the collection search title.

Hi Vectra,

Just found this, as i had the same issue. Better late than never, but you can hide it with the following JavaScript:

  1. paste this in before </body>
<script>
jQuery(document).ready(function() {
    jQuery('.search-result-items a[href^="search-hide"]').each(function() {
        jQuery(this).parent().hide()
    });
})
</script>
  1. Put search-result-items as a class on your search list. Not the wrapper.
  2. Put search-hide inside the slug of the item you wish to hide.

Voila. :handshake:

Just had a client request this without needing to change slugs to avoid SEO stuff and 301 redirecting.

Here is an approach that can be used with a CMS field instead of the slug incase anyone has the same request.

  1. Paste this in before </body>
// Get all elements with data-search="toggle"
const toggleElements = document.querySelectorAll('[data-search="toggle"]');

// Iterate through each toggle element
toggleElements.forEach(toggleElement => {
  const innerHTML = toggleElement.innerHTML.trim();
  
  // Check if innerHTML starts with "hidden"
  if (innerHTML.startsWith("hidden")) {
    // Find the closest parent element with data-search="result"
    const resultParent = toggleElement.closest('[data-search="result"]');
    
    // Set the display style to "none" if a result parent element is found
    if (resultParent) {
      resultParent.style.display = "none";
    }
  }
});
  1. Add the data-search=“result” to the result item on the search results page:

  2. Add the data-search=“toggle” to a text element in the result item that is bound to the search description:

  3. Create a dropdown field in the CMS collection and give it an option of “hidden”:
    Screenshot 2023-09-27 at 11.00.45 am

  4. Add the CMS field into the CMS collections Template Search settings "Search Description field:
    Screenshot 2023-09-27 at 11.00.25 am