• Is it possible to use a shortcode that will display a search form inside post content? If so, what is the shortcode? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @anefarious1,

    As far as I know this theme doesn’t have search shortcode, however that doesn’t mean you can’t create your own ??

    You can add below code to your child theme functions.php or create mu-plugin for it and after that you can use this shortcode anywhere in your content: [my_search_shortcode]
    Code:

    function custom_search_shortcode() {
    
    	get_search_form();
    
    }
    add_shortcode( 'my_search_shortcode', 'custom_search_shortcode' );

    Cheers,
    Predrag

    Thread Starter anefarious1

    (@anefarious1)

    Thanks that worked. Problem is, when I use the shortcode, it automatically appears just under the post title. It doesn’t display where I actually inject the shortcode. Very strange.

    Hi @anefarious1,

    Apologies for the delay here, and I actually made a mistake in above code, this can be done much cleaner and without it popping up on top of the page.

    Please replace above code with this one and that should be it:
    add_shortcode('my_search_shortcode', 'get_search_form');

    Cheers,
    Predrag

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Shortcode for Search Form?’ is closed to new replies.