Submenu results – make sticky

[ad_1]

Yes. Add this to your theme functions.php:

add_filter( 'relevanssi_live_search_configs', function( $configs ) {
    $configs['default']['results']['static_offset'] = false;
    return $configs;
} );

Hi, thank you for your message.

Tried it but did not work.

I have the following CSS to make the primary navigation/search bar appear only on scrolling down. Is it possible this is causing a conflict?

Is there a way to fix this?

.home nav#mobile-header:not(.is_stuck) .inside-navigation.grid-container.grid-parent, .home .main-navigation:not(.is_stuck) {
display: none;
}

  • This reply was modified 2 hours, 37 minutes ago by Allinop.
  • This reply was modified 2 hours, 37 minutes ago by Allinop.
  • This reply was modified 2 hours, 36 minutes ago by Allinop.

The problem is that the results box is not in the search bar; it’s at the bottom of the page.

Did you have to use add_filter( 'relevanssi_live_search_add_result_div', '__return_false' ); to get the search working in the first place? Not using that would be good.

I tried moving the results element inside the form tag of the search form, and that worked: that way the search results element stays sticky at the top of the page.

EDIT: no i did not have to use that one.

To clarify, I want the submenu of live searches to remain sticky not only when I scroll through the submenu itself but also when I scroll through the rest of the page.

You can see an example the effect I am trying to achieve on the following website: example – Google Search

  • This reply was modified 2 hours, 28 minutes ago by Allinop.
  • This reply was modified 2 hours, 24 minutes ago by Allinop.

I do apologize, I am not sure I understand how to fix this. I am trying to get the submenu live search sticky when scrolling through the rest of the page or when I scroll through the submenu itself

The results element is at the bottom of the page. If it were in the search form, this would work correctly.

Now, by default, Relevanssi places the results element inside the form. That’s why I was asking about the filter function, which would set this up the way it is now.

Where is the search form coming from? Does your theme have a searchform.php file that contains the search form? If it does, it’s possible to modify the searchform.php so that the results element appears inside the search form and sticks correctly.

Hi, I have now disabled the:

add_filter( 'relevanssi_live_search_add_result_div', '__return_false' );

The sticky now works fine so that’s sorted.

The only minor issue that remains is that the submenu is not aligned very well, it goes off further to the right side. The above filter corrected it but caused the submenu not being sticky, so now is deactivated

  • This reply was modified 1 hour, 11 minutes ago by Allinop.

Try this in your CSS:

#rlvlive_2 {
    left: -315px;
    position: relative;
    top: -50px;
}

Thank you, it now works perfectly!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer