Skip to content

Instantly share code, notes, and snippets.

@Musilda
Created September 29, 2016 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Musilda/d55c6a84ff0e36d271ea5171b8308ab6 to your computer and use it in GitHub Desktop.
Save Musilda/d55c6a84ff0e36d271ea5171b8308ab6 to your computer and use it in GitHub Desktop.
add_action( 'init', 'set_virtual' );
function set_virtual(){
$args = array(
'post_type' => 'product',
'posts_per_page' => -1
);
$products = new WP_Query( $args );
var_dump(count($products->posts));
foreach( $products->posts as $item ){
update_post_meta( $item->ID, '_virtual', 'yes' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment