Scroll to top

How to Add Search Form in your Post with a WordPress Search Shortcode

Share on facebook
Share on google
Share on twitter
Share on linkedin
function wpbsearchform( $form ) {

    $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
    <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
    <input type="text" value="' . get_search_query() . '" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />

    return $form;

add_shortcode('amitworkdesk', 'wpbsearchform');

Now add [amitworkdesk] as a shortcode in anywhere you want the search bar.

Recent Posts

envato iconUpwork Profile