Tag Info

Hot answers tagged

7

If we peek into the global $wp_taxonomies variable we see the associated object types. There might be better ways to do this or even core functions, but you could try the following: function wpse_172645_get_post_types_by_taxonomy( $tax = 'category' ) { global $wp_taxonomies; return ( isset( $wp_taxonomies[$tax] ) ) ? ...


5

You can do the reverse with get_object_taxonomies. Combine it with get_post_types to iterate over post types to check the taxonomies registered for each. EDIT- Here's an example that produces the same output as @birgire's function, without using dirty globals. function wpse_172645_get_post_types_by_taxonomy( $tax = 'category' ){ $out = array(); ...


2

I believe you are looking for is_tax()and not has_term(). has_term() just basically checks if a post belongs to a given term, while is_tax() on the otherhand checks whether or not you are on a taxonomy archive page. So, you can change this code if ( !has_term('juice', 'types' ) ): to if ( !is_tax( 'types', 'juice' ) ): This simply means that if the ...


1

Here is the code that worked for me in a page template (my parent id was 7): <?php $wcatTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC', 'parent' => 7, )); foreach($wcatTerms as $wcatTerm) : $wthumbnail_id = get_woocommerce_term_meta( $wcatTerm->term_id, 'thumbnail_id', true ); $wimage = ...



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