Tag Info

Hot answers tagged

2

You can make use of the hide_empty argument of get_terms(), it defaults to true. Do it somewhat like this: $args = array( 'hide_emty' => false ); $terms = get_terms( 'wpsc_product_category', $args );


2

WordPress' terms and taxonomies are spread over three tables in the database. Those tables are wp_terms, wp_term_relationships and wp_term_taxonomy - see the codex article on Database Description for more details. The parent relationship is part of the wp_term_taxonomy table, so you should inspect the differences between your environments in this table. ...


1

If you want an example of how to do the dropdown filtering using ajax, then if you factor out your taxonomy dropdown into your "functions.php": function my_dropdown_categories( $taxonomy, $current_selected = '', $include = null ) { // Get all terms of the chosen taxonomy $terms = get_terms($taxonomy, array('orderby' => 'name')); // our ...


1

I may suggest not combining each of these into hierarchical taxonomies, but setting up 3 distinct taxonomies. It seems like they are 3 unrelated properties of the photos, and thus, I would separate the code for them. Then you're not trying to code around nested taxonomy terms, but you can access them each individually. The taxonomies would be color, location ...


1

You use the hide_empty argument for $terms, but not for $this_term inside your loop. Also, with the way you're generating your select, it would be a lot more efficient to just query top-level terms for the main loop: $terms = get_terms( 'device', array( 'hide_empty' => false, 'parent' => 0 ) ); And then drop if($term->parent == 0) {... inside ...


1

There is no default way to sort terms randomly. There are ways to do this using php. First, you'll need to remove the number argument from get_terms. As your code currently stands, you are getting 5 terms and shuffling them around. For this to work, you'll need to retrieve all the terms from your taxonomy, shuffle that returned array randomly with the php ...



Only top voted, non community-wiki answers of a minimum length are eligible