wordpress custom search box for my new theme - php

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.

Related

Using a static HTML page to access WordPress search

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>

Resizing bootstrap form box not working when <span> tag is removed

I'm trying to resize a form box using .col-md-12. It works fine if I keep the code inside the span tag as it is, but if I take it off (and I want to, because I need to remove that button) it stops working. In this scenario the form box will maintain some kind of default size, no matter which value is inserted after -md.
Could anyone give some help? If it matters, this HTML file is part of the viewer of a project using laravel framework.
<div class="box-body">
<div class="col-md-12">
<div class="form-group">
<label for="name">{{ 'name' }}</label>
<div class="input-group">
<input class="form-control" type="text" name="name" value="{{ $name }}">
<span class="input-group-btn">
<a class="btn btn-warning" href="{{ url('path', $id) }}" title="{{ 'edit' }}"><i class="fa fa-pencil"></i></a>
</span>
</div>
</div>
</div>
</div>
Provided that I understood your question right, just add the btn class to the span tag and remove the a tag.
<span class="input-group-btn btn">
<!-- removed button -->
</span>

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

Bootstrap button input group wont display correctly with <form> tags

So I'm working on a social networking Facebook type proof of concept project for college and I'm trying to get a Bootstrap, multi-button input group to display properly for a comment box.
I would like to have the text area, with a Comment and Like button on the right hand side, with the whole input group filling the width of the panel as seen below.
Trying to achieve this!
The problem is when I add in my <form> tags, the formatting of the entire group within <div class="row"> goes crazy and forms a little box on the left hand side (screenshot below).
If I take out the <form> tags formats properly, but I'm just not sure how to manage the <form> tags/where to put them to achieve this multi-button group.
How it displays currently
The code below is a few undos later to when the forms weren't broken, just so you know this isn't how I originally went about achieving it, but what i've succumbed to for now.
If anyone knows how to achieve this I'd be so grateful!
while($row = mysqli_fetch_assoc($result)) {
//Get relative timestamp for current post
$timestamp = strtotime($row['StatusTimestamp']);
$stampRelative = CheckTimestamp($timestamp);
echo '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">'.$row['UserName'].'<small class="postTimestamp"> '.$stampRelative.'</small></h3>
</div>
<div class="panel-body">
'.$row['StatusContent'].'
</div>
<div class="panel-footer clearfix">';
echo ' <div class="row">
<div class="col-lg-11">
<div class="input-group">
<form action="'.CommentOnStatus($row['StatusID']).'" method="post">
<input type="text" class="form-control" name="comment" placeholder="Post a comment...">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">Comment</button>
<input type="hidden" name="statusId" value="'.$row['StatusID'].'">
</span>
</form>
</div>
</div>
<div class="col-lg-1">
<form action="'.LikeStatus($row['StatusID']).'" method="post">
<button type="submit" id="like" name="'.$row['StatusID'].'" class="btn btn-primary pull-right">Like</button>
</form>
</div>
</div>
</div>
</div>';
}
I checked your code. This should work fine. Let me know if this does not work. THere are minor problems of placing the elements. Please Use this in your row :
<div class="col-lg-11">
<form method="post">
<div class="input-group">
<input type="text" class="form-control" name="comment" placeholder="Post a comment...">
<span class="input-group-btn">
<button class="btn btn-default" style="border-width: 1px 0 1px 0;border-radius: 0;" type="submit">Comment</button>
<button type="submit" id="like" name="'" class="btn btn-primary" style="border-radius: 0 5px 5px 0;">Like</button>
</span>
<input type="hidden" name="statusId" value="">
</div>
</form>
</div>
This is my output
Use the classnavbar-form in your form. It should work fine now.
So form will look like <form action="'.CommentOnStatus($row['StatusID']).'" method="post" class="navbar-form">

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