• Resolved Sameer Humagain

    (@sameerhumagain)


    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’);

Viewing 1 replies (of 1 total)
  • jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

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

Viewing 1 replies (of 1 total)
  • The topic ‘meta_key, meta_value not working’ is closed to new replies.