Forums
Forums / Plugin: WooCommerce / meta_key, meta_value not working
(@sameerhumagain)
6 years, 11 months ago
Hello ,
Meta Query is not working with latest Version 3.6.1 . It will display all the category available.
<?php $args = array( ‘hide_empty’ => 0, ‘taxonomy’ => “product_cat”, ‘meta_key’ => “feature_category”, ‘meta_value’ => “1” ); $query = get_terms($args); ?>
<?php print_r($query) ?>
And not able to use the :
function hpr_category_ordering($sort_args) { $sort_args[‘meta_key’] = ‘feature_category’; $sort_args[‘meta_value’] = ‘1’; return $sort_args; }
add_filter(‘woocommerce_product_subcategories_args’, ‘hpr_category_ordering’);
(@jessepearson)
Automattic Happiness Engineer
6 years, 7 months ago
@sameerhumagain This code works for me, but only outputs the Uncategorized category:
function meta_query_not_working() { $args = array( 'hide_empty' => 0, 'taxonomy' => 'product_cat', 'meta_key' => 'feature_category', 'meta_value' => '1', ); $query = get_terms( $args ); print_r( $query ); } add_action( 'wp_head', 'meta_query_not_working' );
The meta_key feature_category is not default to WooCommerce, which may be part of the issue.
feature_category
The topic ‘meta_key, meta_value not working’ is closed to new replies.