Created
March 28, 2020 00:02
-
-
Save lelandf/ade5aa6132bf4035b5098f826456082e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* No warranty or support offered. Please use at your own risk */ | |
function leland_learndash_update_course_meta() { | |
$course_args = array( | |
'post_type' => 'sfwd-courses', | |
// Please be careful with unbounded queries | |
// This is not going to work well if you have a lot of courses | |
// Test on a staging/dev server first! | |
'posts_per_page' => -1, | |
); | |
$course_query = new WP_Query( $course_args ); | |
if ( $course_query->have_posts() ) { | |
while ( $course_query->have_posts() ) { | |
$course_query->the_post(); | |
// Get the course meta | |
$meta = get_post_meta( $course_id, '_sfwd-courses', true ); | |
// Update access mode to "Buy Now" | |
$meta['sfwd-courses_course_price_type'] = 'paynow'; | |
// Change price to "4" | |
$meta['sfwd-courses_course_price'] = '4'; | |
update_post_meta( get_the_ID(), '_sfwd-courses', $meta ); | |
} | |
} | |
} | |
add_action( 'init', 'leland_learndash_update_course_meta' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment