Archived topic
Search on specific page
5 replies · Started by Benny on July 21, 2020
Hey there, i wanted to include a Search Box with this Snippet
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 make it search for things on one specific page. Is this even possible to search on one page only?
Hi there,
can you explain a little more?
1. Will the search form be on all pages ?
2. What results do you want it to return ?
No, it should be a searchbox on one page for this same page. In the end i'm planning a searchable faq page with a search form whose results are only from this page.
All search plugins i am aware of only search the database.
Most users would resort to CTRL + F or in page search on mobile browsers for this kind of function.
But i found this JS which taps into the browser find:
http://www.javascripter.net/faq/searchin.htm
Or you could create your own search engine:
Ok, thank you. I will have a look into it :)
You're welcome