Tag Info

New answers tagged


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] ) ) ? ...


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(); ...


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 = ...


Your query explicitly excludes the current post with this: 'post__not_in' => array($post->ID), remove that and it will return the current post within the results.


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 ...


There's a sql script written by someone else that does the job - updates counts for product categories in woocommerce or any other category counts. Only takes a few seconds to run as well: http://stackoverflow.com/questions/18669256/how-to-update-wordpress-taxonomiescategories-tags-count-field-after-bulk-impo


What do you mean by "dynamic" ? Do you want it to work with different posts? If so, that's simple. Before your get_posts query function, get page terms, and pass them to your array. You can get taxonomies with <?php get_the_terms( $yourpostid, 'your_custom_taxonomy'); ?>

Top 50 recent answers are included