M
M
mobylm2020-05-11 17:31:59
WooCommerce
mobylm, 2020-05-11 17:31:59

How to display images of Woocommerce products with the same meta attribute?

Hello!
Can you please tell me how to display images of Woocommerce products with the same meta attribute? It is desirable that the images be wrapped with a link to this product.
There is a meta slug, it is desirable to search for it.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2020-05-11
@wppanda5 WooCommerce

Individual product attributes are stored in meta_fields _product_attributes
Accordingly, it is necessary to work as with ordinary custom fields

$args = [
      'post_type'  => 'product',
      'meta_query' => [
        [
          'key'     => '_product_attributes',
          'value'   => 'blue',
        ]
      ]
    ];

$query = new WP_Query($args);

then go through the standard cycle and do everything you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question