In Wordpress / WooCommerce I want to search by Category but somehow I cant get it to work.
The normal Search works and gives me this url http://localhost:8888/rwdr/search/[searchkeyword]
how does the url look like when searching in a category?
<form role="search" method="get" id="searchform2" action="" class="">
<ul class="radio-ul">
<li>
<label for="typBA" class="typ typBA "></label>
<input name="category" id="typBA" value="BA" type="radio">
</li>
<li>
<label for="typBAX7" class="typ typBAX7 "></label>
<input name="category" id="typBAX7" value="BAX7" type="radio">
</li>
<li>
<label for="typBASL" class="typ typBASL "></label>
<input name="category" id="typBASL" value="BASL" type="radio">
</li>
</ul>
<label for="InputBox">Input Box</label>
<input type="text" value="" id="first" name="s" />
<input type="hidden" value="" name="x" /> </form>
I really appreciate any help!
You can do a search using standard query in your url
yoursite.com/?post_type=product&taxonomy=product_cat&term=your_category_slug&s=a
To get the URL, you can build a form like this,
<form method="get" action="" role="search">
<input type="hidden" name="post_type" value="product">
<input type="hidden" name="taxonomy" value="product_cat">
<input type="hidden" name="term" value="your_category_slug">
<input type="search" name="s" value="">
<input type="submit" value="Search">
</form>
In WordPress, I use a plugin called "Search Everything", where you can set if you want to add categories, tags and many other options to the search results. It's pretty easy to use and it works fine to me.
Related
I am trying to follow along here in my book when building my website, I am trying to work on PHP/ .pl form saving, but I cannot seem to get it to work like it should.
<form action="/cgi-bin/contactlist.php" method="post">
<fieldset>
<legend>Join E-mail List Test blah blah</legend>
<p>This is a test and I am curious what it does so lol </p>
<ol>
<li>
<label for="name">Name:</label>
<input type="text" name="name" id="name" />
</li>
<li>
<label for="email">Email:</label>
<input type="text`enter code here`" name="email" id="email" />
</li>
</ol>
<input type="submit" value="Submit" />
</fieldset>
</form>
</body>
</html>
The code listed above, but the form is not saving like it should, any suggestions?
I have this form
<form role="search" method="get" id="searchform" class="searchform" action="http://search.site.com/Archive/search/read" >
<div>
<input type="text" value="" placeholder="text" name="query" id="?" />
<input type="submit" id="searchsubmit" value="." />
</div>
</form>
I need to add this suffix at the end of the url: &title=&start_year=&end_year=
For example:
http://search.site.com/Archive/search/read?query=pertini&title=&start_year=&end_year=
Where the query is: pertini
Is it possible in JavaScript or jQuery or in PHP?
Site only support GET method.
I am working in WordPress.
Just add hidden fields for all the ones you need:
<form role="search" method="get" id="searchform" class="searchform" action="http://search.site.com/Archive/search/read">
<div>
<input type="text" value="" placeholder="text" name="query" id="?" /><input type="submit" id="searchsubmit" value="." />
</div>
<input name="title" type="hidden" value="" />
<input name="start_year" type="hidden" value="" />
<input name="end_year" type="hidden" value="" />
</form>
How do I make this code (custom):
<div id="sb-search" class="sb-search">
<form>
<input class="sb-search-input" placeholder="Search.." type="text" value="" name="search" id="search">
<input class="sb-search-submit" type="submit" value="">
<span class="sb-icon-search"></span>
</form>
</div>
retrieve search results like this one ( wordpress ) does:
<form method="get" class="searchform" action="<?php echo home_url('/'); ?>">
<div>
<input type="text" class="search" name="s" onblur="if(this.value=='')this.value='<?php _e('To search type and hit enter','typegrid'); ?>';" onfocus="if(this.value=='<?php _e('To search type and hit enter','typegrid'); ?>')this.value='';" value="<?php _e('To search type and hit enter','typegrid'); ?>" />
</div>
Basically I got this custom code for an awesome search box with on-click slide etc. It has a field where people can type, but it gets no results as used on my wordpress site. I wanna make it able to get results from wordpress content w/o changing divs thus not altering its design. Please help, I'm stuck!!
This would do it:
<div id="sb-search" class="sb-search">
<form action="<?php echo home_url('/'); ?>">
<input class="sb-search-input" placeholder="Search.." type="text" value="" name="s" id="search">
<input class="sb-search-submit" type="submit" value="">
<span class="sb-icon-search"></span>
</form>
</div>
All you have to do is add the form action, and make the name of the search input to be "s".
<form method="get" class="searchform" action="<?php echo home_url('/'); ?>" >
<input class="sb-search-input" placeholder="Search.." type="text" value="" name="s" id="search">
<input class="sb-search-submit" type="submit" value="">
<span class="sb-icon-search"></span>
</form>
homeurl ?s=anything will call wordpress search function, so just make form's action GET and ACTION = your home url
I'm having form and page(Template Page) in WP. Through form, I want send values GET, then the page create query.
form:
<form id="homepage_form" method="get">
<input type="hidden" name="p" value="48" />
<input class="first" type="text" name="name" />
<input type="text" name="location"/>
<select name="category">
<option value="0" disabled selected>Kategori</option>
</select>
<input class="btn" type="submit" value="Search" />
</form>
First Question. Do I need send id page in form?(input type="hidden" name="p" value="48"). Maybe is other method.
Second Question. When I sent this form, I saw "page_id_48/?location=asdasd". WP stolen second GET (name).
Now I know... I don't like forms in WP or I don't understand.
you need the attribute value , in order to GET it.
<input class="first" type="text" name="name" value="something" />
In WP can't to send get 'name'
<input class="first" type="text" name="name" />
<- bad
<input class="first" type="text" name="notname" /> <- ok
I have a GET form at the top of my page, but it is not yet configured. All I have for it is this:
<div class="top-search">
<form method="get" id="searchform" action="#">
<div>
<input type="text" value="Search..." name="s" id="s" onfocus="defaultInput(this)" onblur="clearInput(this)" />
<input type="submit" id="searchsubmit" value=" " />
</div>
</form>
</div>
How can I manipulate this to use Google CSE?
Seeming as no one decided to answer it, I found out for myself.
<div class="top-search">
<form id="searchform" action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="xxxx" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" value="" name="q" id="q" autocomplete="off" />
<input type="submit" id="searchsubmit" name="sa" value=" " />
</div>
</form>
</div>
Where "xxxx" is your Search Engine Unique ID, found on the Basics page of your control panel.