Filtering Posts by Custom Taxonomy PHP function? Not working?
-
Not sure how to make this work but this is the custom taxonomy I created:
function add_custom_taxonomies() { global $va_options; // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => __( 'Listing Local Places', APP_TD ), 'singular_name' => __( 'Listing Local Place', APP_TD ), 'search_items' => __( 'Search Listing Local Places', APP_TD ), 'all_items' => __( 'All Local Places', APP_TD ), 'parent_item' => __( 'Parent Listing Local Place', APP_TD ), 'parent_item_colon' => __( 'Parent Listing Local Place:', APP_TD ), 'edit_item' => __( 'Edit Listing Local Place', APP_TD ), 'update_item' => __( 'Update Listing Local Place', APP_TD ), 'add_new_item' => __( 'Add New Listing Local Place', APP_TD ), 'new_item_name' => __( 'New Listing Local Place Name', APP_TD ), 'not_found' => __( 'No Listing Local Places found', APP_TD ), 'not_found_in_trash' => __( 'No Listing Local Places found in trash', APP_TD), 'add_or_remove_items' => __( 'Add or Remove Listing Local Places', APP_TD ), 'menu_name' => __( 'Local Places', APP_TD ), ); $args = array( 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false, 'hierarchical' => true, 'query_var' => true, 'rewrite' => array( 'slug' => $va_options->listing_permalink . '/' . 'local' ), ); register_taxonomy( VA_LISTING_LOCAL_PLACE, VA_LISTING_PTYPE, $args ); } add_action( 'init', 'add_custom_taxonomies', 0 );
This allows me to place posts within different locations… for example, http://www.domain.com/local/new-york/ or http://www.domain.com/local/florida/
I’m using a homepage widget to make featured or other posts appear. What I’d like to do is filter them by the location. So if someone selects “new york” with a drop down, then only posts in new york will appear.
I was using the
<?php if ( get_term( 'new-york', 'local', $listings->the_post() ) ) : ?> post code here <?php endif; ?>
but the posts in new york weren’t appearing correctly. Am I using the wrong php function?
thank you
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Filtering Posts by Custom Taxonomy PHP function? Not working?’ is closed to new replies.