Skip Navigation

[Resolved] Scroll to ID on search results page

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by marcialB 2 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#2021043

Hi there

We have a search page where I use this code to scroll to the results when changing the search:

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function() {
jQuery('html, body').animate({ scrollTop: jQuery("#search-results").offset().top-180}, 'slow');
});

Now I'd like to use the same effect when coming to the search results page from a search field placed on a different page. We have a search field on our main page. But when opening the search results page, it doesn't scroll. I Is it possible to add the ID as an anchor in the shortcode?

{!{wpv-form-view name='only-search' target_id='123'}!}

Where I have "123" I would like to be able to set the URL including the ID, e. g. /search-page#search-results.

It that possible?

Thanks for your help.

#2021119

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Marcial,

Thank you for getting in touch.

Based on what you're saying the search results page is different from the search page itself.

Do it like this.

jQuery( document ).ready(function() {
jQuery('html, body').animate({ scrollTop: jQuery("#search-results").offset().top-180}, 'slow');

});

The scroll should now activate when you navigate to the page after it has fully loaded.

Please let me know if this helps.
Thanks,
Shane

#2021173

Thanks a lot, that works perfect!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.