Articles of custom taxonomy

Display empty taxonomy terms with get_terms()

I have a function setup as follows: <?php $terms = get_terms(“wpsc_product_category”); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ foreach ( $terms as $term ) { ?> <li class=”calendar-filter-menu-item” data-filter=”.<?php echo $term->slug; ?>”><?php echo $term->count; ?></li> <?php } } ?> Which displays the taxonomy slug and count for each taxonomy, only problem is […]

Add description to custom taxonomy admin metabox

I’ve created a custom taxonomy: add_action( ‘init’, ‘create_collection_taxonomies’, 0 ); function create_collection_taxonomies() { $labels = array( ‘name’ => _x( ‘Collection Tags’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Collection Tag’, ‘taxonomy singular name’ ), ‘search_items’ => __( ‘Search Collection Tags’ ), ‘popular_items’ => __( ‘Popular Collection Tags’ ), ‘all_items’ => __( ‘All Collection Tags’ ), […]

How to use wp_terms_checklist() on front end

Getting a Fatal Error using wp_terms_checklist() in one of my advanced search form in Front End. Fatal error: Call to undefined function wp_terms_checklist() With search I got that it’s creating problem because the function is for admin panel use only, BTW not deprecated. <?php $args = array( ‘descendants_and_self’ => 0, ‘selected_cats’ => false, ‘popular_cats’ => […]

pre_get_posts Tax Query not working for custom author page

I am using the theme TwentyTwelve and modified the standard post query in the file author.php with the following code: function wpd_author_query( $query ) { //CODE to set $current_user_name here //This gets the author from the URL $author = get_user_by(‘slug’,get_query_var(‘author_name’)); $current_user_name = $author->user_nicename; if ( $query->is_author() && $query->is_main_query()) { // your code to set $current_user_name […]

How to Add Custom Taxonomy To Woocommerce Plugin

I am trying to add a Custom Taxonomy to Woocommerce by targeting the product post type in Woocommerce. I used following code and added it into functions.php I am not getting any error message but the taxonomy is not showing in the Woocommerce as well. Can you please let me know how I can do […]

List only first-level children of specific custom taxonomy term

I have a site set up with the following: Post Type: product Taxonomy: product_cat Taxonomy Slug: hydro The term hydro has several immediate child terms and several grandchild terms. I need to write a loop that will display only the first-level children of the custom taxonomy term “hydro” (i.e – skip grandchild terms), along with […]

Get direct children of custom taxonomy

I’ve googled extensively and tried my best, but I just can’t get the first level children of the custom taxonomy in the code below to work! It only displays the parent level. What I am trying to achieve is the following: Level 1 <— at the moment, it only displays this level Level 2 <– […]

How to count the number of terms in a taxonomy

I have a custom post type “Services”. It has a hierarchal taxonomy of “service-category”. Service-category has both parent and child terms. I need to count the number of parent terms in the taxonomy. NOT posts. The # of terms in the taxonomy is being used in my code to layout the page in a recursive […]

Taxonomy landing pages

I like to create a landing page for my custom taxonomies. Right now ive created three custom taxonomies /country/[terms] /person/[terms] /interrests/[terms] i like to create a listing page for each of the taxonomy, this listing page should list all the [terms] they contain. And link to the normal (taxonomy-[term].php /taxonomy/[term]) url. What is a proper […]

Is it possible to create a shortcode that will query a post based on taxonomies?

I am working on a site that will be listing a few hundred products and we wanted to be able to quickly/easily show specific products on a page based on taxonomies. I have been doing some research and thought I was on the right track. First, I found this article on digwp.com which I thought […]