Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WP All Import / WooCommerce issue
Plugin Name: WooCommerce - Create missing visible field
Plugin URL:
Description: Create missing visible field
Version: 0.1
Author: Remi Corson
Author URI:
Contributors: corsonr
Text Domain: none
Domain Path: languages
add_action( 'init' , 'wc_create_missing_field' );
* Create Missing fields in WC
* @access public
* @since 1.0
* @return void
function wc_create_missing_field() {
global $wpdb;
$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE 'post_type' = 'product'");
foreach( $post_ids as $post_id ) {
$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '_visible' WHERE meta_key = '_visibility' AND post_id = '$post_id'");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.