How to display custom taxonomy and terms using/creating plugin template

In the taxonomy-user_image_category.php the get_queried_object method will return the term object, which you can incorporate to your WP_Query. From top of my head, in your case it may look like this: $queried_object = get_queried_object(); $term_id = $queried_object->term_id; $args = array( ‘post_type’ => ‘user_images’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘sui_image_category’, ‘field’ => … Read more

Get Parent Custom Taxonomy Term and Color Div background

You’ll have to adjust the markup to suit your specific needs, but the easiest solution would use a post_class filter on the post_class() template tag, to output appropriate classes. For example, in your template, you need to call post_class(), such as: <div <?php post_class(); ?>> <div class=”car_type”>Ford</div> (background green) Post Title<br> Post Content<br> </div> Then, … Read more

Can’t pull metadata for a term in my theme’s function.php

woocommerce_add_to_cart_validation is a filter that is run in the add_to_cart_action method of the WC_Form_Handler class. This method is attached to the init hook. add_action( ‘init’, array( $this, ‘add_to_cart_action’ ) ); Your taxonomy is quite probably also registered at the init hook. The WooCommerce action has no priority set, so the default would be 10. I … Read more

Non-Recursive get_term_children()

Presumably you want to output term data, so you can use get_terms with the child_of argument, then iterate over returned terms and check that the parent of each term is your main term id: $parent_id = 42; $children = get_terms( ‘product_category’, array( ‘child_of’ => $parent_id ) ); foreach( $children as $child ) { if( $parent_id … Read more