Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$20
Taxonomy Search Dropdown
It sounds like similar a dropdown search for 'States' and then a dropdown search that display the 'Cities' of the selected State.
Thanx.
This question has been answered.
natspace | 06/28/12 at 7:59am
Edit
(3) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
06/28/12
8:09amJatin Soni says:This search form with dropdown I have done for custom post type.
Now here you need to replace all your texonomy terms
<form class="searchcat" role="search" method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<div class="rowElem">
<input type="text" value="" name="s" id="s" placeholder="search here..." tabindex="1" /><select name="post_type">
<option value="">All Type</option>
<option value="video">Video</option>
<option value="audio">Audio</option>
<option value="gallery">Gallery</option>
<option value="portfolio">Portfolio</option>
</select>
<input type="submit" id="searchsubmit" value="Search" tabindex="2" />
</div>
</form>
Also you can use something like this to get automatically
<form role="search" method="get" id="searchform" action="<?php bloginfo('home'); ?>">
<div>
<input type="text" value="" name="s" id="s" />
<?php
function get_terms_dropdown($taxonomies, $args){
$myterms = get_terms($taxonomies, $args);
$optionname = "optionname";
$emptyvalue = "";
$output ="<select name='".$optionname."'><option selected='".$selected."' value='".$emptyvalue."'>Select a Category</option>'";
foreach($myterms as $term){
$term_taxonomy=$term->YOURTAXONOMY; //CHANGE ME
$term_slug=$term->slug;
$term_name =$term->name;
$link = $term_slug;
$output .="<option name='".$link."' value='".$link."'>".$term_name."</option>";
}
$output .="</select>";
return $output;
}
$taxonomies = array('YOURTAXONOMY'); // CHANGE ME
$args = array('order'=>'ASC','hide_empty'=>true);
echo get_terms_dropdown($taxonomies, $args);
?>
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>Previous versions of this answer: 06/28/12 at 8:09am
- 06/28/12 8:34am
Jatin Soni says:This is tested with search function and works completely fine Just copy and paste :)
function get_terms_dropdown($taxonomies, $args){
$myterms = get_terms($taxonomies, $args);
$output ="<select>";
foreach($myterms as $term){
$root_url = get_bloginfo('url');
$term_taxonomy=$term->taxonomy;
$term_slug=$term->slug;
$term_name =$term->name;
$link = $root_url.'/'.$term_taxonomy.'/'.$term_slug;
$output .="<option value='".$link."'>".$term_name."</option>";
}
$output .="</select>";
return $output;
}
?>
<form class="searchcat" role="search" method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<div class="rowElem">
<input type="text" value="" name="s" id="s" placeholder="search here..." tabindex="1" /> <?php
$taxonomies = array('Your_Texonomy');//change Your_Texonomy to yours
$args = array('orderby'=>'count','hide_empty'=>true);
echo get_terms_dropdown($taxonomies, $args);
?>
<input type="submit" id="searchsubmit" value="Search" tabindex="2" />
</div>
</form>
Just replace Your_Texonomy with your texonomy name like video_category etc
- 06/28/12 8:34am
-

Last edited:
06/28/12
8:21amArnav Joy says:this will output all the terms of taxonomy
<?php
$tax_name = 'category'; // replace this with your taxonomy name
$terms= get_terms( $tax_name , 'orderby=count&hide_empty=0' );
$count = count($terms);
if ( $count > 0 ){
echo "<select>";
foreach ( $terms as $term ) {
echo "<option value=".$term->term_id.">" . $term->name . "</option>";
}
echo "</select>";
}
?> -

Last edited:
06/28/12
8:23amDaniel Yoen says:try this tutorial :
http://www.aroundwp.com/multiple-taxonomies-in-a-dropdown-menus/
:)Previous versions of this answer: 06/28/12 at 8:23am
- 06/28/12 12:48pm
Daniel Yoen says:I think you need this JSON script :
Put this script where you want to show the drop down :
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#json_options").change(function(){
var json_option = $("#json_options").val();
$("#json_post").empty().append("<option>loading...</option>"); //show loading...
var json_url = "<?php echo get_template_directory_uri(); ?>/index-json.php?json_option=" + encodeURIComponent(json_option);
$.getJSON(json_url,function(data){
$("#json_post").empty(); //clear states selections
if(data==""){
$("#json_post").append("<option value=\"0\">No states found</option>");
}
else{
for(i=0; i<data.id.length; i++){
$("#json_post").append("<option value=\"" + data.id[i] + "\">" + data.name[i] + "</option>");
}
}
});
return false;
});});
</script>
<?php
function get_terms_dropdown($taxonomies, $args)
{
$myterms = get_terms($taxonomies, $args);
foreach ($myterms as $term)
{
$term_taxonomy = $term->taxonomy;
$term_slug = $term->slug;
$term_name = $term->name;
$link = $term_slug;
$output .= "<option value=" . $term_slug . ">" . $term_name . "</option>";
}
return $output;
}
$taxonomies = array('TAXONOMY'); // REPLACE WITH YOUR OWN TAXONOMY
$args = array('orderby' => 'count','hide_empty' => true);
?>
<select name="json_options" id="json_options">
<option value="0">Select here</option>
<?php echo get_terms_dropdown($taxonomies, $args); ?>
</select>
<select name="json_post" id="json_post"></select>
Then, create a file with a name index-json.php in your theme folder, fill with this cript :
<?php
define('WP_USE_THEMES', false);
require_once('../../../wp-load.php');
$json_option = $_GET['json_option'];
$json = array();
$args=array('post_type' => 'YOUR POST TYPE', 'YOUR TAXONOMY' => $json_option); // REPLACE WITH YOUR OWN
$jasonquery=new WP_Query($args);
if($jasonquery->have_posts())
{
while ($jasonquery->have_posts())
{
$jasonquery->the_post();
$json['id'][] = get_the_ID();
$json['name'][] = get_the_title();
}
header('Content-Type: text/javascript; charset=UTF-8');
echo json_encode($json);
}
wp_reset_postdata();
?>
hope this help :)
Daniel
- 06/28/12 12:48pm
This question has expired.
natspace voted on this question.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
