get_term_children returns WP_Error for custom taxonomy

Since get_term_link() will return a WP_Error object if the term does not exist, you could try: $termchildren = get_term_children( $taxID, $taxType ); echo ‘<ul>’; foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxType ); $term_link = get_term_link( $term->name, $taxType ); if( ! is_wp_error( $term_link ) ) echo ‘<li><a href=”‘ . $term_link … Read more

Set a taxonomy as private

You should also set the query_var to false. So your args array should be like this: $args = array( ‘labels’ => $labels, ‘public’ => false, ‘query_var’ => false, ‘rewrite’ => false, ‘hierarchical’ => false, ); Cheers

List subcategory on taxonomy term page

You can make use of get_term_children() instead of get_categories() You can try something like this $term = get_queried_object(); $term_id = $term->term_id; $taxonomy_name = $term->taxonomy; $termchildren = get_term_children( $term_id, $taxonomy_name ); echo ‘<ul>’; foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name ); echo ‘<li><a href=”‘ . get_term_link( $term, $taxonomy_name ) . … Read more

Programatically added attribute, set to ‘show on product page’ automatically. Woocommerce [closed]

It actually doesn’t matter because WooCommerce uses this, to display: $values = wc_get_product_terms( $product->id, $attribute[‘name’], array( ‘fields’ => ‘names’ ) ); However, if you don’t set the display to true, you’d have to add this code to your template files. You might have to do other things as well (styling, etc). If you just set … Read more

How to add autocomplete to custom taxonomy for CPT

The logic in the tax query is very unlikely to verify true. Look at it: ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘zip_code’, ‘field’ => ‘slug’, ‘terms’ => array( $term ), ), array( ‘taxonomy’ => ‘city_served’, ‘field’ => ‘slug’, ‘terms’ => array( $term ), ), ), If you read the tax query, it … Read more

Sorting taxonomy columns by meta value numeric

The code I am posting is a modified and simplified version of yours. I got my solution using your code. /** * Filter WP_Term_Query meta query * * @param object $query WP_Term_Query * @return object */ function filter_terms_clauses( $pieces, $taxonomies, $args ) { global $pagenow, $wpdb; if(!is_admin()) { return $pieces; } if( is_admin() && $pagenow … Read more