• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Logo

impressive pages: Webdesign und eCommerce

  • Home
  • Blog
  • Hosting
  • Contact
Start » Blog » Activate reviews for all products in WooCommerce (bulk)

Activate reviews for all products in WooCommerce (bulk)

22. December 2021 Leave a Comment

Activating ratings for all products works programmatically with the following code:

add_action('admin_init', 'iphf_enable_reviews');

function iphf_enable_reviews() {

    $args = array(
        'post_type'   => 'product',
        'numberposts' => -1,
        'comment_status' => 'closed',
        'post_status' => 'publish',
    );

    $shop_products = get_posts( $args );
    foreach( $shop_products as $item){
        $product = new WC_Product($item->ID);
        wp_update_post( array(
            'ID'    => $item->ID,
            'comment_status' => 'open',
        ) );
    }
}

Insert this code in the functions.php or use it as a plugin and open the admin panel once. After that, all products should have reviews activated. The code can then be removed again.

Filed Under: WooCommerce

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Search

Recent Posts

  • WooCommerce: Show free shipping only
  • Remove wrapper DIVs (.wrap) in Genesis
  • Remove the number of products in the category list from the category name
  • Change the number of similar products in WooCommerce
  • Genesis Visual Hook Guide

Categories

  • development
  • Genesis framework
  • Google Search Console
  • mobile
  • SEO
  • Uncategorized
  • Web hosting
  • WooCommerce
  • WordPress

Archives

  • May 2022
  • January 2022
  • December 2021
  • imprint
  • Data protection

Footer

!pages
Heinrich Franz
Wilhelm-Martin-Str. 4
76356 Weingarten (Baden)
instagram
+49 160 85 40 725
info@impressive-pages.de

In my Blog I publish articles about WordPress, Genesis framework und SEO.

© 2022 impressive pages

  • Deutsch