How to navigate to an HTML anchor after search

Do you want the Search Bar to navigate to an HTML anchor on the page after a search is performed? If so, you can add the following code to your site:

/**
 * Modify the action of the Search Bar form to navigate to #site-content anchor after search
 *
 * @param string $url Where the form submits to.
 *
 * @returns string Modified URL with anchor added
 */
add_filter( 'gravityview/widget/search/form/action', function ( $url ) {
	return $url . '#site-content';
} );

Read here how to add these code samples to your website: Where to put code samples.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us