Recently, one of our regular users asked if there was an easy way to add WordPress search form in his post or page content with a shortcode. Well, the answer to that question is yes. In this article, we will show you how to add WordPress search form to your post or page content by creating a WordPress search shortcode.
All you have to do is open the functions.php file of your theme or a site-specific plugin and paste the following code:
add_shortcode ('wpbsearch', 'get_search_form');
Then use the shortcode in your post/page content like so:[wpbsearch]
This will display the default search form. If you want to display a custom search form, you can do it like this:
función wpbsearchform ($ form) $ form = ''. __('Buscar:') . ''; devuelve $ form; add_shortcode ('wpbsearch', 'wpbsearchform');
We hope the article will help all those who wanted to create a search form shortcode in WordPress.