Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function adopt_custom_taxonomy_dropdown( $taxonomy, $orderby = 'date', $order = 'DESC', $limit = '-1', $name, $show_option_all = null, $show_option_none = null ) {
- $args = array(
- 'orderby' => $orderby,
- 'order' => $order,
- 'number' => $limit,
- );
- $terms = get_terms( $taxonomy, $args );
- $name = ( $name ) ? $name : $taxonomy;
- if ( $terms ) {
- printf( '<select name="%s" class="postform">', esc_attr( $name ) );
- if ( $show_option_all ) {
- printf( '<option value="0">%s</option>', esc_html( $show_option_all ) );
- }
- if ( $show_option_none ) {
- printf( '<option value="-1">%s</option>', esc_html( $show_option_none ) );
- }
- foreach ( $terms as $term ) {
- printf( '<option value="%s">%s</option>', esc_attr( $term->slug ), esc_html( $term->name ) );
- }
- print( '</select>' );
- }
- }
- //The following is then used to pull the results onto a results template:
- ?>
- <?php
- if (isset($_GET["farm-type"]) && empty($_GET["location-farms"])){
- $farm_type = $_GET["farm-type"];
- $myquery1['tax_query'] = array(
- array(
- 'taxonomy' => 'farm-type',
- 'terms' => array($farm_type),
- 'field' => 'slug',
- ),
- );
- query_posts($myquery1);
- }
- ?>
- <?php
- if (isset($_GET["farm-type"]) && isset($_GET["location-farms"])){
- $farm_type = $_GET["farm-type"];
- $farm_location = $_GET["location-farms"];
- $myquery2['tax_query'] = array(
- array(
- 'taxonomy' => 'farm-type',
- 'terms' => array($farm_type),
- 'field' => 'slug',
- ),
- array(
- 'taxonomy' => 'location-farms',
- 'terms' => array($farm_location),
- 'field' => 'slug',
- ),
- );
- query_posts($myquery2);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement