Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // select some posts and loop through them to do something
- // code goes in functions.php for your child theme
- // see https://codex.wordpress.org/Template_Tags/get_posts for all possible arguments
- $args = array(
- 'post_type' => 'post',
- 'post_status' => 'any',
- 'numberposts' => -1 );
- $selected_posts = get_posts( $args );
- foreach( $selected_posts as $post ) {
- setup_postdata($post);
- $post_id = get_the_ID();
- set_post_type( $post_id, 'product' );
- add_post_meta( $post_id, '_price', ' >>> PRICE <<< ', true);
- add_post_meta( $post_id, '_regular_price', ' >>> PRICE <<< ', true);
- add_post_meta( $post_id, '_visibility', 'visible', true);
- add_post_meta( $post_id, '_stock_status', 'instock', true);
- }
- wp_reset_postdata();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement