Using a static HTML page to access WordPress search - php

So I have a .html page under my Wordpress website and I want to be able to use the search button on the static html page to search WordPress using the native search.php page, is that possible?
Is this correct? This is located inside my test.html:
<div class="search_bar-wrapper">
<input type="text" class="search_bar search-input evt-search-input-wp" placeholder="Search"
value="<?php echo get_search_query(true); ?>"/>
<button class="btn-fh btn-secondary search-btn search-btn-overlay">
<i class="custom-icon icon-icon_small_arrow_right"></i>
</button>
<div class="clearInput"><img src="/images/icon_close.svg" alt="" /></div>
</div>
Would I need to point a form="submit" and action=".." on the input instead? If so, what would the action need to point too?

Yes You Can did by add this code in your html page and Change Form Action Url With Your Wordpress Url
<div class="search_bar-wrapper">
<form action="https://wordpressdomainhere.com/" method="get">
<input type="text" name="s" class="search_bar search-input evt-search-input-wp" placeholder="Search Here"/>
<button class="btn-fh btn-secondary search-btn search-btn-overlay">
<i class="custom-icon icon-icon_small_arrow_right"></i>
</button>
<div class="clearInput"><img src="/images/icon_close.svg" alt=""/></div>
</form>
</div>

Related

is it possible to send user entered keyword through anchor tag in php

i have a searchbox in my website like below:
<div style="" class="col-sm-8">
<div class="wrapda">
<div class="searchda">
<a href="https://google.com">
<input type="text" class="searchTermda" placeholder="Search Image">
<button type="submit" class="searchButtonda">
<i class="fa fa-search">Search</i>
</button>
</a>
</div>
</div>
</div>
am trying to pass the user entered keyword in the input box to next page , is there anyway to do this using anchor tags, please help. thanks in advance
Instead of using anchor tag, the more standard way is to use form.
<div style="" class="col-sm-8">
<div class="wrapda">
<div class="searchda">
<form method="POST" action="your target url">
<input type="text" name="searchInput" class="searchTermda" placeholder="Search Image">
<button type="submit" class="searchButtonda">
<i class="fa fa-search">Search</i>
</button>
</form>
</div>
</div>
</div>
You have to specify the action attribute in the form tag which will be your target url.
You also have to specify the name attribute in the input tag.
This way your input will be sent to your target url.
You can use form for this purpose.
<form action="https://www.google.com/search" method="GET" />
<input type="text" placeholder="Search Image" name="q" />
<input type="submit" value="Search Image" />
</form>

using <div> <form> and GET together?

i have a home page which has navigation sidebar and a search bar. if i modify the code to make search work navigation wont work and vice versa. Heres the code. Please help
<div class="w3-bar w3-black">
Home
Message
Friends
Notification
<div class="w3-dropdown-hover">
<button class="w3-button">Dropdown</button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
Settings
Log-Out
</div>
</div>
<form action="result.php" method="GET">
<input type="text" name="query" class="w3-bar-item w3-input" style="color:#000" placeholder="Search.."/>
<button class="w3-bar-item w3-button w3-green">GO</button>
</div>
right now when i click the navigation bar icon. it goes to search result. and with GET method and the form tag navbar will not open.
You should close the form tag
<form action="result.php" method="GET">
<input type="text" name="query" class="w3-bar-item w3-input" style="color:#000" placeholder="Search.."/>
<button type="submit" class="w3-bar-item w3-button w3-green">GO</button>
</form>
otherwise the form is not well formed and can't submit the values
and add the type submit to the button
Better, your code will be looks like this
<div class="w3-bar w3-black">
Home
Message
Friends
Notification
<div class="w3-dropdown-hover">
<button class="w3-button">Dropdown</button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
Settings
Log-Out
</div>
</div>
<?php if(isset($_GET['query'])): ?>
<form action="result.php" method="GET">
<input type="text" name="query" class="w3-bar-item w3-input" style="color:#000" placeholder="Search.."/>
<button class="w3-bar-item w3-button w3-green">GO</button>
</form>
<?php endif ?>
</div>
hope this answer will help you out from your problem

wordpress custom search box for my new theme

Hi friends i am beginner for wordpress.i create a wordpress own theme for content management.daily add a new post in mysite.i want to see specific post.so i need a search box.create a search box but not working in mysite.any one please help me i can't undestand this problem
my coding
searchform.php
<div class="collapse navbar-collapse" id="search">
<form role="search" method="get" action="<?php echo home_url( '/'); ?>" id="searchform">
<div class="search">
<div class="input-group">
<input class="form-control lg" id="inputdefault" placeholder="Search Mergosoft.com" type="search" value="" name="s">
<span id="search-btn-submit" class="btn lg btn-primary input-group-addon hidden-xs"><i class="fa fa-search"></i></span>
<span class="btn xs btn-primary input-group-addon hidden-sm hidden-md hidden-lg"><i class="fa fa-search"></i></span>
</div>
</div>
</form>
</div>
search.php
enter code here
problem is i want to search type the input field and submit button page loading but can't get the result.loading after redirect to homepage.
mysite :https://www.mergosoft.com/
thanks for seeing my question
It looks like you have a redirect from / to /en-in/. The
Template fails to load because/?s=test is being redirect to /en-in/?s=test
Try removing this redirect and see if the search template loads up.

Submit Button Only Working on Index Page

Been having trouble with a form not submitting data to a page (Change Password) when on any page of the website apart from the index page (Which is working as it should). The website is built using CodeIgniter.
The code currently used on all pages for the form is the following:
<div class="modal-body">
<form role="form" id="change_password_form" action="<?php echo base_url('auth/change_password')?>" method="post">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="Old Password" name="old" type="password" autofocus>
</div>
<div class="alert alert-danger" id="old" role="alert" style="display:none"></div>
<div class="form-group">
<input class="form-control" placeholder="New Password - minimum 8 characters" name="new" type="password" value="">
</div>
<div class="alert alert-danger" id="new" role="alert" style="display:none"></div>
<div class="form-group">
<input class="form-control" placeholder="Confirm New Password" name="new_confirm" type="password" value="">
</div>
<div class="alert alert-danger" id="new_confirm" role="alert" style="display:none"></div>
<input type="hidden" name="user_id" value="<?php echo $user_id;?>" id="user_id" />
</fieldset>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="changepassword" value="Submit">Submit</button>
</form>
</div>
On the index page, this successfully goes to the change_password function and will check the details to see if they meet the rules. An error message is shown below the text box when submit is clicked. However on other pages using the same code, nothing happens when submit is clicked. when I go into Main.php and change the page of index.php in the index function to any other page (view_inventory.php for example), The change password works correctly on the new index page, but will not work on the old index page.
I can get the change password to work on other pages if I replace the submit button with the code below (Doesn't show the results under the text boxes, but on a new blank page), but I didn't really want to have to edit so many pages if it can be fixed in a smaller amount.
<input type="submit" value="Submit" class="btn btn-primary">
Any help would be gratefully appreciated.
I had the same error last week. you have to use a Submit inside form instead of button.
You can use form_submit for example:
echo form_submit('mysubmit', 'Submit');
// Would produce: <input type="submit" name="mysubmit" value="Submit" />
Here is the documentation:
http://www.codeigniter.com/user_guide/helpers/form_helper.html
Regards.

What is wrong with this form? It does not seem to post (get)

See the search form of this website in question:
http://www.xyzai.com/academia/
It just defaults back to the original main page.
This is very odd, because it seems the form is set up properly.
<form action="http://www.xyzai.com/academia/" class="search-form standard-search" method="get" role="search">
<div class="input-group">
<input type="search" title="Search for:" name="s" value="" placeholder="Search …" class="search-field form-control">
<span class="input-group-btn">
<button class="btn btn-default search-submit" type="submit" id="searchsubmit"><i class="fa fa-search"> </i></button>
</span>
</div><!-- /input-group -->
</form>
What is causing this?
BY REQUEST, MORE INFO:
It appears when Wordpress's permalinks are turned off (default settings) things work great. Otherwise, no search is accomplished.
Buddypress was hijacking wordpress's search.
I had to add this to wp-config.php
define ( 'BP_SEARCH_SLUG', 'find' );

Categories