I have a custom search bar which works fine on my Wordpress home page, however when I place it on a different page of the site, the URL keeps directing to http://localhost/pageName/?s=searchTerm instead of http://localhost/?s=searchTerm. I've tried setting form action to
<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
and also hardcoding my site URL but the redirect happens every time.
Here is my searchform.php file:
<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div>
<input type="text" value="<?php echo the_search_query(); ?>" name="s" id="s" placeholder="Search" />
</div>
</form>
How would I get the form to direct to http://localhost/?s=searchTerm?
Just write
<form method="get" id="searchform" action="/">
Related
I have a WP site on http://subdomain.example.com and a Magento site at http://example.com.
I was wondering what is the easiest way to add a Magento search box on the WP installation?
This is the WP search box code, but i dont know what parameter to modify since i have no idea how Magento works :(
<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" />
<input type="submit" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" />
</div>
</form>
Any help would be greatly appreciated!
You can make a php script that gets the data from the magento site every time someone searchs . that would probably be the simplest way.
Put the Magento catalogsearch url in the form action, and an input field with name attribute value "q" such as:
<form method="get" action="http://example.com/catalogsearch/result/">
<input type="text" value="" name="q" />
I have a problem.
My website is running an SSL on the checkout page. This is the current message I get.
The page at 'https://jonathanmichael.co.uk/checkout/' was loaded over
HTTPS, but is submitting data to an insecure location at
'http://jonathanmichael.co.uk/': this content should also be submitted
over HTTPS.
<form action="http://jonathanmichael.co.uk/" method="get" id="adminbarsearch"><input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150"><input type="submit" class="adminbar-button" value="Search"></form>
My question is how do I fix this? I'm using Wordpress, I have found this code which I think links to it.
searchform.php
<!-- Start SearchForm -->
<form method="get" class="searchform" role="search" action="<?php echo home_url(); ?>/">
<fieldset>
<input name="s" type="text" id="s" placeholder="<?php _e( 'Search', THB_THEME_NAME ); ?>" class="small-12">
</fieldset>
</form>
<!-- End SearchForm -->
I have zero knowledge of PHP for help would be appreciated.
Thanks!
Easy. Just explicitly change the form action to:
<form action="https://jonathanmichael.co.uk/checkout/"
Also, please use $_POST for your form.
$_GET should not be used for anything that is supposed to be secure.
<form action="https://jonathanmichael.co.uk/checkout/" method="POST" id="adminbarsearch">
You need to pass the $scheme parameter to the call to home_url()
This will let you generate the link with the https:\\ prefix.
See the documentation: http://codex.wordpress.org/Function_Reference/home_url
<!-- Start SearchForm -->
<form method="get" class="searchform" role="search" action="<?php echo home_url($scheme = https); ?>/">
<fieldset>
<input name="s" type="text" id="s" placeholder="<?php _e( 'Search', THB_THEME_NAME ); ?>" class="small-12">
</fieldset>
</form>
<!-- End SearchForm -->
I am fleshing out my first custom Wordpress theme and trying to hook up the search. Now I am following the codex but does not appear to be working correctly. Perhaps I am doing something wrong?
I have added the theme support as this is using the HTML field method.
so here is my search field:
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
<label>
<input type="search" class="search-field" placeholder="What are you looking for?" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
</label>
<br />
<button class="button-search">Find items</button>
</form>
And I have created a search.php with the usual template page bits along the top, created the search page as a page in wordpress, yet when I search I can see the post request in the URL but the page is blank. I am cleary doing something wrong here?
This should work for you
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label>
<input type="text" class="search-field" placeholder="What are you looking for?" value="<?php echo get_search_query() ?>" name="s" id="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
</label>
<br />
<input type="submit" class="button-search" id="searchsubmit" value="Find items" />
</form>
I'm making a Wordpress template on my own. On the top of the header, there is a fixed search input, so the user can search for any posts with a determinate tag whenever he wants to.
The problem is that when I type a tag keyword on the input, it always shows all the posts, not filtering any of it at all.
But when I search for a keyword that has no tag registered, it returns a 404.php error page.
One curious thing is that when there is a tag keyword, the link appears like this:
/wordpress/tag/name-of-the-tag/
And when there is no tag with that keyword, it appears as:
/wordpress/?tag=name-of-the-tag/
My form code is right below:
<form method="get" action="<?php echo esc_url( home_url( '/' ) );?>">
<input id="s" type="text" name="tag" onfocus="if (this.value=='Buscar...') this.value = '';" onblur="if (this.value=='') this.value = 'Buscar...'" name="search" class="form-search" value="Buscar..."/>
</form>
You've add the name attribute twice. With a value tag and search. Remove all of them and add a name="s"
This is from CODEX
<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" />
<input type="submit" id="searchsubmit" value="<?php echo esc_attr_x('Search', 'submit button'); ?>" />
</div>
</form>
ok i have a problem with the search i'm creating a new blog in wordpress and it's not working at all i tried a lot and nothing change
this is the header.php code
<div class="navbar-r">
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<input class="in-s-n" type="text" name="s" <?php the_search_query();?> />
<input class="su-s-n" type="submit" value="Find" />
</form>
</div>
<!--End navbar-r-->
and when i search the page get blank
what do i have to do? any help
Try using something like:
<form role="search" method="get" id="searchform" class="searchform" action="<?php esc_url( home_url( '/' )); ?>">
<div>
<label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label>
<input type="text" value="<?php get_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="<?php esc_attr_x( 'Search', 'submit button' ); ?>" />
</div>
For more details, check out this link: http://codex.wordpress.org/Function_Reference/get_search_form