1

Where in the database can I find that a product is marked "featured"? I have marked 4 products as featured but I have yet to find out how to retrieve this information from any the database tables.

Thank you.

2 Answers 2

1

Since 3.0 featured products are marked as featured by being given the featured term that WooCommerce creates in the product_visibility taxonomy.

But to tell if a product is featured, instead of checking the terms directly or using get_post_meta() (which wouldn't work anymore anyway), use the get_featured() method of WC_Product:

$product_id = 1;
$product = wc_get_product( $product_id );
$featured = $product->get_featured();
1
  • veeery nice . veeery good Commented Dec 24, 2017 at 6:30
1

Featured Products Loop in WooCommerce 3

<ul class="products">
<?php
    $args = array(
        'post_type' => 'product',
        'posts_per_page' => 12,
        'tax_query' => array(
                array(
                    'taxonomy' => 'product_visibility',
                    'field'    => 'name',
                    'terms'    => 'featured',
                ),
            ),
        );
    $loop = new WP_Query( $args );
    if ( $loop->have_posts() ) {
        while ( $loop->have_posts() ) : $loop->the_post();
            wc_get_template_part( 'content', 'product' );
        endwhile;
    } else {
        echo __( 'No products found' );
    }
    wp_reset_postdata();
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.