I want to make a search button that search only within my website.
- Do I need external PHP or PERL script?
- Can it done by JavaScript?
- Or simply by HTML.
I tried to create a form using HTML:
<form>
<input type="search" name="banner_search" class="banner-text-box" >
<input type="submit" name="" value="SEARCH" class="banner-text-btn">
</form>
I want to make a search button that search only within my website.
- Do I need external PHP or PERL script?
- Can it done by JavaScript?
- Or simply by HTML.
I tried to create a form using HTML:
<form>
<input type="search" name="banner_search" class="banner-text-box" >
<input type="submit" name="" value="SEARCH" class="banner-text-btn">
</form>
Share
Improve this question
edited Oct 17, 2016 at 6:37
Dave Romsey
17.9k11 gold badges56 silver badges70 bronze badges
asked Oct 17, 2016 at 6:12
Govind JangidGovind Jangid
311 silver badge6 bronze badges
2 Answers
Reset to default 1You can use WordPress's internal search by calling the get_search_form()
function:
<?php get_search_form(); ?>
get_search_form()
will use a default HTML form, but you can create your own custom form by adding a searchform.php
file to your theme.
You can add this HTML form to your page
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div>
<label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label>
<input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" class="banner-text-box" />
<input type="submit" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" class="banner-text-btn"/>
</div>
</form>
Refrence:
- Default HTML Form