Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Add a Search Form in a WordPress Post

Do you want to add a search form to a WordPress post?

By adding a search bar to your post’s content, you can help visitors find more great content and keep them on your site for longer.

In this article, we’ll show you how to add a search form in a WordPress post.

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

Why Add a Search Form to Your Posts and Pages?

If a visitor has enjoyed a post on your WordPress website, then it’s likely they’ll want to read more. By adding a search form to a post you can help visitors find more blogs they’re interested in reading.

In this way, you can increase your pageviews and reduce your bounce rate.

The longer visitors stay on your website, the greater chance they’ll join your email list, leave a comment, make a purchase, follow you on social media, or take other positive actions.

In this guide, we’ll show you how to add the standard WordPress search form to your posts. If you want to use a custom form instead, then see our step-by-step guide on how to create a custom WordPress search form.

Having said that, let’s take a look at how to easily add a search form in a WordPress post. Just use the quick links below to jump straight to the right method you want to use.

Method 1. How to Add a Search Form in a WordPress Post (Works With All Themes)

The simplest way to add a search form to your posts is by using the built-in Search block.

A search bar in a WordPress post

In this guide, we’ll show you how to add the block to a post, but you can also add it to any page or widget-ready area of your site.

To get started, simply open the page where you want to add a search form. In the WordPress content editor, click on the + icon.

In the popup, type in ‘Search.’ When the right block appears, click to add it to the page.

Adding the search block to a WordPress post

By default, the block uses ‘Search’ for both its label and the button text. This text will be visible to visitors, so you may want to replace it with something more descriptive.

For example, if you’re adding the search bar to a WordPress blog, then you might want to use ‘Search recent blog posts’ or similar.

Changing the search bar heading

You can even use the label and button text to motivate your visitors.

For example, if you’ve created an online store using a plugin such as WooCommerce then you might use something like ‘Find more great deals’ or ‘Search for similar offers.’

You can also add some placeholder text. This text will disappear automatically when the visitor starts typing.

To add a placeholder, simply click on ‘Optional placeholder…’ and then start typing.

Adding a placeholder to the WordPress search bar

By default, WordPress will use your theme to style the search bar.

However, you can change the button’s background and text color using the ‘Color’ settings in the right-hand menu. This can help your search bar stand out from the rest of your site.

Customizing the WordPress search button in a post

When you’re happy with how the Search block looks, you can go ahead and either publish or update the post. If you visit your site, you’ll now see the search bar within the post’s content.

You can add a search form to more WordPress posts and pages following the same process above. For detailed instructions on how to add the Search bar to a sidebar or similar section, please see our guide on how to add and use widgets in WordPress.

Method 2. How to Add a Search Form to All WordPress Posts (Block-Based Themes)

If you’re using a block-based theme such as ThemeIsle Hestia Pro, then you can add a search bar to the template that WordPress uses for all your blog posts.

In this way, you can quickly and easily add a search bar to every single blog post across your entire WordPress website.

To open the full-site editor, go to Themes » Editor in the WordPress dashboard.

Opening the WordPress full-site editor (FSE)

By default, the full site editor shows your theme’s home template.

To see all the available options, select ‘Templates’ from the left-hand menu.

Adding a search form to a WordPress blog using the FSE

This shows a list of all the templates that make up your WordPress theme.

To customize the blog template, go ahead and click on ‘Single.’

Adding a search form to a WordPress blog using the full-site editor

WordPress will now show a preview of the blog layout.

To go ahead and edit this template, click on the small pencil icon.

Adding a search form to a WordPress blog using the full-site editor

You will now see this template in the full-site editor.

To go ahead and add a search bar, click on the blue ‘+’ icon.

Adding a search bar to a WordPress blog template

In the popup that appears, type in ‘Search’ to find the right block.

You can now drag the block to the location where you want to show the search bar.

Adding a search block using the WordPress full-site editor

To customize the block title or placeholder text, simply type the new messaging into the search block.

When you’re happy with how the block looks, click on ‘Save’ to make the search bar live.

Customizing the search bar using the full-site editor (FSE)

Now, if you visit any blog post on your site, you’ll see the search bar.

The Search block uses WordPress’ built-in search feature. However, this is quite limited and not very good at showing accurate results.

That’s where SearchWP comes in.

SearchWP is the best custom search plugin for WordPress. It gives you complete control over the WordPress site search so you can deliver more accurate results to your visitors.

SearchWP also makes all parts of your site searchable, including PDF files, ACF files, text files, WordPress custom fields, and more.

After creating a custom search form, you can add it to any part of your website using either a block or shortcode.

Adding an advanced search form to a website or blog

To learn more, please see our guide on how to improve WordPress search with SearchWP.

We hope this tutorial helped you learn how to add a search form in a WordPress post. You may also want to learn how to create a contact form in WordPress or check out our expert pick of the best email marketing services for small businesses.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

34 CommentsLeave a Reply

  1. Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Thank you, but I’m seeing only {wpbsearch] on the page I want the search form to be. I’m not sure if I’m placing the add_shortcode(‘wpbsearch’, ‘get_search_form’); code in the correct place in the theme functions.php file. I placed the following code in a perceived function location: between /** and * is_it woocommerce_page- Returns true if on a page which uses WooCommerce…) in the actual page I want to search, as I want it to be a page-only search, (and is this the correct code to do that?)

    The Page Code:
    function wpbsearchform( $form ) {

    $form = ‘

    ‘ .
    _(‘Search Timeline For:’) . ‘


    return $form;

    add_shortcode(‘wpbsearch’, ‘wpbsearchform’);

  3. thank you so much for this. It was so easy. I have been searching for how to do this for months but was looking in the wrong places.

  4. I want to add a general google search bar -not custom search just a general google search box so users will not have to leave the page to conduct a google search.

  5. Hi there!
    You guys are really the best (y)
    Great post once again.
    I’ve been able to add the search form with visual composer as well. So, maybe someone will give it a try :)

    Finaly, I’m trying to add a search form in a slideshow like this site:

    I’ll be more than glad if someone here do have a trick for this.

    Thanks again and stay blessed

  6. Just what I was looking for, thank you! What would an example be of CSS if we wanted to change the colors and text of the search bar? (i.e. what would we add to CSS to change the colors/text/etc.)?

  7. This was stupid easy to implement. I wrote it as a plugin so I can use on MultiSite :) Thank you for the write-up.

  8. Hello,

    Is it possible to make this search form to search only a particular category?

    Example. I have 5 Categories – Cat 1, Cat 2, Cat 3, Cat 4 and Cat 5.

    I want the search from only on page 4 and the search form should search only from Cat 3?


  9. Hi,
    really love your tutorials!

    Is it possible to define the search for comments within each post I put the shortcode? So that it’s not a global search, but a search of the comments just of the post I’m searching at via the shortcode. Would be amazing for helping me out, don’t find anything.


  10. Hi, I have just used this script on my theme. Thanks for the help. And its working. But i have one problem, I want to edit the title of that search form how to do. Please help me out.

    Sandeep Kumar Dan

  11. Awesome tip! Thanks for posting, it is just what I was looking for. I wanted something simple so that people can search through exercise videos and this fit the bill.

  12. Great article! I created a short code and then tweaked the CSS to position and size it the way I wanted.

    add_shortcode(‘prodSearch’, function($atts) {
    global $woocommerce;

    echo ”;
    echo ”;


    • Greg… what was your custom form code for your woocommerce search form you mention here?

      I am trying to get two search boxes into a top navigation one for standard wordpress site search the other for woocommerce products..

    • Hi Greg!
      Thank you for this tip!.. Do you know how to change the search box text and css for this shortcode??
      Any help would be greatly appreciated..

  13. Just used it in my WP site. Was able to add search box anywhere I like.

    Thank you! This one’s simpler and easy to use compared to the plugins out there.

  14. Great little tutorial. I tried to embed this shortcode within a column shortcode, but it just appears at the top of the page, instead of within the column. Is there something I need to add?

  15. i read your site everytime when you put something new. I want to know if is posible to put search form for my google search..Now i used search default from wordpress but i dont like very good the results and i want to know if is posible to put “google search” just for my content. i hope you understand, i try to write correct english but i’m not so good. i wait your answer if is posible. i appreciate your site and your work.

  16. Hi,

    Thank you for the tip .
    Don’t forget to use different IDs to avoid duplication of FOR and ID’s values.
    Here you use exactly the same as default WordPress’ search form.

    Thank you,

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.