最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

how to get woocommerce product id by acf field in wordpress and display product

programmeradmin1浏览0评论
$product_cat_object = get_queried_object();
        $axy = get_field('select_artists', 'product_cat_' . $product_cat_object->term_id);  

       $args = array(
    'post_type' => 'product',
    'tax_query' => array(
        array(
            'taxonomy' => 'product_cat',
        'posts_per_page' => 100,
            'terms'    => array(var_dump($axy) ),
        ),
    ),
);
$product_cat_object = get_queried_object();
        $axy = get_field('select_artists', 'product_cat_' . $product_cat_object->term_id);  

       $args = array(
    'post_type' => 'product',
    'tax_query' => array(
        array(
            'taxonomy' => 'product_cat',
        'posts_per_page' => 100,
            'terms'    => array(var_dump($axy) ),
        ),
    ),
);
Share Improve this question edited Jul 5, 2019 at 6:57 Jacob Peattie 44.2k10 gold badges50 silver badges64 bronze badges asked Jul 5, 2019 at 6:54 varsha choudharyvarsha choudhary 12 bronze badges 2
  • 1 var_dump() is not the right function to use there. It prints information about the variable and doesn't return anything. – Max Yudin Commented Jul 5, 2019 at 7:16
  • 1 Can you please explain how ACF field, product_cat and product are linked with each other, with respect to your query? I'm confused with the question. – Aniruddha Gawade Commented Jul 5, 2019 at 9:16
Add a comment  | 

1 Answer 1

Reset to default -1

Use only $axy instead of 'terms' => array(var_dump($axy) ), ... It will work, surly. Try it.

        'terms' => $axy,
发布评论

评论列表(0)

  1. 暂无评论