Archived topic
Search form within a page possible?
3 replies · Started by Roman on February 18, 2017
Hello Tom,
I have a crazy idea. Is it possible to place a search form into a page or a section like this?
https://www.omnea.de/verzeichnisse/branchenorte/
I would like to place the search more prominent.
Roman
Hi Roman,
You could build a shortcode which you can use like this:
add_shortcode( 'search', 'tu_search_shortcode' );
function tu_search_shortcode() {
ob_start();
get_search_form();
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
Then just use [search] in your content.
Hello Tom. Revisiting this, but tell me if I should start a new topic. Is there a way to constrain this search to the page that it's on? For example, there are a lot of things on a site that I'm building related to the same words, but I only want to see results on the one page where I put the search bar. Possible?
I don't think it's possible to modify WordPress get_search_form(); this way.
Might be worth asking on a general forum like this and see if anyone has a clever solution:
https://wordpress.stackexchange.com/