I'm having issues with the default WordPress search bar. The search bar no longer brings up any related post results. Sorting by categories also just results in being sent to blank template pages instead of redirecting to the 404 page.
I haven't been able to find any useful answers or tutorials on how to even begin approaching fixing a broken search bar. All the tutorials just say to install search plugins like Relevanssi, which I tried and it didn't help.
If anyone knows how search query code works in WordPress, any info would be greatly appreciated.
Edit:
This is the website link and searchform.php in question, if that helps any. https://www.animationpagoda.com/
<?php
/**
* Searchform
*
* Custom template for search form
*/
?>
<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div class="large-12 columns">
<div class="collapse">
<div class="large-8 mobile-three columns">
<input type="text" name="s" id="s" placeholder="<?php esc_attr_e( 'Write a keyword...', 'magneti' ); ?>" />
</div>
<div class="large-4 mobile-one columns">
<input type="submit" class="button prefix" name="submit" id="searchsubmit" value="Search" />
</div>
</div>
</div>
</form>
Related
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>
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.
I am creating a WP theme. My search function does not work well.
When I hit the Search button nothing happens, it doen't even refresh the page. But when I type in the URL www.example.com/?s=Lorem I get the results. I don't understand why my search button does not work. Can anyone tell me how can I fix this problem? Below you will see my search.php and searchform.php
search.php
<?php get_header(); ?>
<main role="main">
<!-- section -->
<section>
<h1><?php echo sprintf( __( '%s search-form Search Results for ', 'mytheme' ), $wp_query->found_posts ); echo get_search_query(); ?></h1>
<?php get_template_part('loop'); ?>
</section>
<!-- /section -->
</main>
<?php get_footer(); ?>
searchform.php
<div id="search">
<button type="button" class="close" style="background:transparent;border-radius: 0px;">x</button>
<form method="get" id="searchform" action="<?php echo esc_url(home_url('/')); ?>">
<input type="search" value="" name="s" placeholder="<?php if (!empty($theme_options['search_placeholder'])) { echo $theme_options['search_placeholder']; } ?>" />
<button type="submit" class="btn btn-primary"><?php _e( 'Search', 'mytheme' ); ?></button>
</form>
</div>
May be you miss something. Replace input tag code with following code
<input type="search"
value="<?php the_search_query(); ?>"
name="s"
placeholder="<?php if(!empty($theme_options['search_placeholder'])) {
echo $theme_options['search_placeholder'];
} ?>"
/>
Thank you for your answers.
My initial code above was working fine after I removed
wp_register_script('slick.min', get_template_directory_uri() . '/js/slick.min.js', array('jquery'), '1.0.0', true);
//wp_enqueue_script('slick.min'); // Enqueue it!
from my functions.php
I'm using the default Woocommerce search bar (get_searchform) on my site using the code:
<form role="search" method="get" class="search-form">
<div class="postcode-search col-lg-4 col-lg-offset-4">
<input type='textbox' name="s" class="form-control form-inline" style="display: inline;" id="item-search" value="<?php the_search_query();?>" placeholder="Enter your postcode"/>
<span class="input-group-btn">
<button class="item-search-btn"><span class="">find stores</span></button>
</span>
<?php
if ( function_exists( 'woocommerce_product_search' ) ) {
echo woocommerce_product_search( array( 'limit' => 40 ) );
}
?>
</div>
</form>
It successfully displays the results for all my Woocommerce products but I want it to be used for users to search for product categories only therefore only showing parent product categories and not products.
Does anyone know how I can alter the code above to achieve this?
All suggestions are very welcome and thank you in advance!
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' );