how do you pull data from two taxonomies?

First, get all term slugs from the custom example taxonomy space by current post ID. $space_terms = wp_get_post_terms( $post->ID, ‘space’ ); if( $space_terms ) { $space_terms = array(); foreach( $space_terms as $term ) { $space_terms[] = $term->slug; } } You should specify the logical relationship between each inner taxonomy array when there is more than … Read more

How to appear plural or singular custom taxonomy name(-s) inside woocommerce single product meta php file

The final solution of plural and singular terms name is below. Code <?php $term_ids = wp_get_post_terms( $product->get_id(), ‘variety’, array(‘fields’ => ‘ids’) ); echo get_the_term_list( $product->get_id(), ‘variety’, ‘<span class=”posted_in”>’ . _n( ‘Ποικιλία:’, ‘Ποικιλίες:’, count( $term_ids ), ‘text-domain’ ) . ‘ ‘, ‘, ‘, ‘</span>’ ); ?> In my project is working correct 🙂 Hope to help … Read more

Template taxonomy-{taxonomy}.php doesn’t show my posts

Well, first of all, you are not doing anything with the $term variable. You are querying it, but then it sits there, waiting to be picked up. Try this code in your taxonomy template, called taxonomy-hardware_category.php: // prepare the variables for the query $tax = get_query_var(‘taxonomy’); $term = get_query_var(‘term’); // Setup the loop, build the … Read more

Check if any available product has specific attribute

Here is the code that solved the problem: $woo_args = array( ‘status’ => ‘publish’, ‘limit’ => 1, ‘stock_status’ => ‘instock’, ‘brand’ => 99 ); $products = wc_get_products($woo_args); if (count($products) == 0){ //No product with the custom attribute id=99 } add_filter(‘woocommerce_product_data_store_cpt_get_products_query’, ‘my_handle_custom_query_var’, 10, 2); function my_handle_custom_query_var($query, $query_vars) { if (!empty($query_vars[‘brand’])){ $query[‘tax_query’][] = array( ‘taxonomy’ => ‘pa_brand’, … Read more