Search Results and Custom Headers

Hello,

I found that if i use the standard search on my website the header changes, even though search results and archive page types isn’t configurable within Pro Headers.

If the results of the search have a single product in the results, the Pro Header displays instead of the standard nav header.

https://usatcorp.com/?s=cradlepoint

In my shop Pro Header, i use the Product Search widget so as to display search results as a shopping area instead of an archive style list.

If people are searching in the store, with the product search, I want the Pro Header, since it’s within the store.
If people are searching outside the shop, I want them to get the standard header, regardless of whether or not the search results contain any product links.

Is this possible?

Jesse @ USAT

Hi Jesse,

Thanks for reaching out.

Since it has specific requirement than default header assignments in header builder, then it’s only possible with custom code. Please check these Multisite Global Sections using Pro Theme, Header assigned to a Post category

To put it simply, you’ll need a condition and header ID, example,

is_shop() and header 2328, then the code will be

function custom_header_assignment( $match ) {
  if ( is_shop() ) {
      $match = 2328; // the post ID for your header      
  }
  return $match;
}
add_filter( 'cs_match_header_assignment', 'custom_header_assignment' );

You can use the same code block over and over for every new condition, example,

function custom_header_assignment( $match ) {
  if ( is_shop() ) {
      $match = 2328; // the post ID for your header      
  }

  if ( is_product() ) {
      $match = 2329; // the post ID for your header      
  }

//and more condition and header IDs

  return $match;
}
add_filter( 'cs_match_header_assignment', 'custom_header_assignment' );

This is just the idea of how to achieve it, the question is how you’ll achieve the conditions based on those requirements. For example, what condition is a product search, and how you can determine if the result has a product and convert it into condition? For that, you’ll have to implement a custom coding that we can’t provide here in the forum.

Thanks!

Unfortunately, I don’t follow any of this. I was just hoping i was missing some setting in Pro Headers that would prevent the header from showing on standard search results. Seems like this shouldn’t require a custom solution and should be native to the Pro Headers functionality. You can select where you want it to appear everywhere else, just not when it comes to search results. Seems like an oversight in development.

Hello Jesse,

We certainly appreciate the feedback! Regretfully at this time it’s only possible with custom code however I checked our issue tracker and this has been added as feature request for future development. All of these items are discussed with our team internally and prioritized based on the amount of interest a particular feature might receive.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.