WooCommerce: Don’t show variation attributes on the front-end

Recently imported many products, variations, attributes in to WooCommerce from a CSV file. All the attributes used for variations were set to show on the front-end – whoops!

Two options: Go through each product and uncheck “Visible on the product page” or this bit of code:

    $args = array(
        'post_type'      => 'product',
        'posts_per_page' => -1,

    $products = get_posts($args);
    foreach ($products as $post) {
        $update = false;
        $meta = get_post_meta($post->ID,'_product_attributes',true);
            foreach($meta as $k => $a)
                if($a['is_variation'] && $a['is_visible'])
                    $a['is_visible'] = 0;
                    $update = true;
                    $meta[$k] = $a;


                update_post_meta( $post->ID,'_product_attributes', $meta);

Loops through products, and changes the meta as if the box were unchecked. Use at your own peril – definitely not on a production site!

Leave a Reply

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