Search within the current page


I’m trying to place a second search bar, along with the main navigation search bar, on a specific page within a site so that I can search just within that page. Per the recommendation of someone, I placed the following code in my functions.php file

add_shortcode( 'search', 'tu_search_shortcode' ); function tu_search_shortcode() { ob_start(); get_search_form(); $ret = ob_get_contents(); ob_end_clean(); return $ret; }

and then added the shortcode [search] to the page.

That worked for putting the search bar on that page where I wanted it, but it still searches the entire site like the general search bar does.

Does anyone know if I can limit the search to that specific page?

DanB0328 1 year 2020-07-24T22:10:23-05:00 0 Answers 64 views 0

Leave an answer