A
A
Alexander Srokin2018-05-23 22:20:35
WordPress
Alexander Srokin, 2018-05-23 22:20:35

How to know if a product is recommended (Wordpress + Woocommerce)?

The only option that came to my mind is to get a list of recommended ones, as shown in the code below. Then, when displaying each new product, check whether it is included in the received coveted array and, accordingly, mark it. Are there better ways?

$args = array(
    'post_type' => 'product',
    'tax_query' => array(
        array(
            'taxonomy' => 'product_visibility',
            'field'    => 'name',
            'terms'    => 'featured',
        ),
    ),
);
$featured_goods = new WP_Query( $args );

Thanks in advance for your reply!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
E, 2018-05-24
@evil_genius01

it seems

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question