Wordpress Build Search Form

[WP] | Add a WordPress Search Form in 5 minutes – No code

How to build a WordPress search form for your WordPress website that visitors can use to search for content inside your website. In this article, we will see how you can create a custom WordPress search form using two different methods- by adding code, and not adding code. Make sure that you have also read best search engines for WordPress before following the instructions below.

Wordpress Build Search Form

 

Add wordpress search form

Method 1- WordPress search form by adding code. (Free)

All WordPress sites come with a default search form.

Given that you are here, you want to edit the look and feel of your search form- The placeholder, the submit button, size of the search box, etc you could opt for method 2 which gives you more fine-grained controls.

  • You can add a search form by including the following code in your WordPress template
    <?php get_search_form(); ?>
  • For creating a custom search form, create a new PHP file called searchform.php and save it to your themes folder. You can add the following form code to this file.
    <form role="search" method="get" class="searchform group" action="<?php
    echo home_url('/');
    ?>"> <label> <span class="offscreen"><?php
    echo _x('Search for:', 'label');
    ?></span> <input type="search" class="search-field" placeholder="<?php
    echo esc_attr_x('Search', 'placeholder');
    ?>" value="<?php
    echo get_search_query();
    ?>" name="s" title="<?php
    echo esc_attr_x('Search for:', 'label');
    ?>" /> </label> <input type="image" alt="Submit search query" src="<?php
    echo get_template_directory_uri();
    ?>/images/search-icon.png">
     </form>

     

  • This adds just a search form to your WordPress site which uses the default WordPress search. To have better search functionality on your WordPress site, you could follow the steps below in method 2.

Method 2- WordPress search form using expertrec custom search engine

Add wordpress search form

wordpress search form

 

Method 3: WordPress search form using plugin

TThe following WordPress plugin adds a WordPress search form.

WP Fastest Site Search

 

 

 

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.