WordPress.org

Ready to get started?Download WordPress

Forums

dropdow menu hierarchical not working (1 post)

  1. d3lty
    Member
    Posted 1 year ago #

    hello i'm using a template for a real estate website where there is a search form at the home for the taxonomies: property_location property_type and so on. but for some how the content of the dropdown is not showing on a hierarchical structure even if its set to true.

    //property types drop down
    	if (isset($_GET['property_type'])) { $type_ID = $_GET['property_type']; } else { $type_ID = 0; }
    	if ($type_ID > 0) {
    		//Do nothing
    	} else {
    		$type_ID = 0;
    	}
    	$type_options = array	(
    'hierarchical' 		=> true,
    								'show_option_all'	=> __(stripslashes(get_option('colabs_label_property_type')), 'colabsthemes' ),//__('Select Type'),
    								'hide_empty' 		=> 0,
    								'show_count' 		=> 1,
    								'orderby' 			=> 'name',
    								'name' 				=> 'property_type',
    								'id' 				=> 'find-type',
    								'taxonomy' 			=> 'property_type',
    								'hide_if_empty'		=> 0,
    								'selected' 			=> $type_ID
    								);
    //Get Property Terms
    if(!function_exists('property_terms')){
    function property_terms($args){
    
        $taxonomy = '';
        $name = '';
        $id = '';
        $selected = null;
        $show_option_all = '';
    
    	if ( !is_array($args) )
    		parse_str( $args, $args );
    
    	extract($args);
    
        $terms = get_terms( $taxonomy, 'hierarchical=1' );
        if ($terms) {
        echo '<select name="'.$name.'" id="'.$id.'" class="postform">';
        echo '<option value="">' . $show_option_all .'</option>';
        foreach($terms as $term) {
            if($selected = $term->term_ID){ $selected = 'selected="selected"'; } else { $selected = ''; }
            echo '<option value="'. $term->slug . '" ' . $selected . '>' . $term->name.'</option>';
            }
        echo '</select>';
        }
    }}
    <form method="get" action="<?php bloginfo('url'); ?>" class="">
        <p><label for="find-type"><?php _e( 'Search for Type', 'colabsthemes' ); ?>&nbsp;:</label>
    	<?php
        property_terms($type_options);
        ?>
        <input class="submit" type="submit" value="Pesquisar"/></p>
        </form>

    can someone help me?

Topic Closed

This topic has been closed to new replies.

About this Topic