So take a look at this wp_insert_post. The post_parent contains the ID of the post_type 'courses' that I want to return the post_title of.
$enroll_data = apply_filters('tutor_enroll_data',
array(
'post_type' => 'tutor_enrolled',
'post_title' => $title,
'post_status' => $enrolment_status,
'post_author' => $user_id,
'post_parent' => $course_id,
)
);
// Insert the post into the database
$isEnrolled = wp_insert_post( $enroll_data );
So I'm creating a query with WP_Query but how do I....I guess "customize" the array returned?
$query_args = array(
'author' => current_user_id(),
'post_type' => 'tutor_enrolled',
'post_status' => 'any',
);
// The Query
$the_query = new WP_Query( $query_args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
// I need to take post_parent
}
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
I need to get the post parent and look up that specific post and get the title and ID and somehow return that....maybe as post meta?
tutor_enrolled is just a "text string" meaning the Title is what happened for this data (ie. Course Enrolled). It doesnt have the actual course title or any course data.
I'm also trying to use all of this as a custom query in elementor so I can display the TutorLMS courses the current user is enrolled in.
So take a look at this wp_insert_post. The post_parent contains the ID of the post_type 'courses' that I want to return the post_title of.
$enroll_data = apply_filters('tutor_enroll_data',
array(
'post_type' => 'tutor_enrolled',
'post_title' => $title,
'post_status' => $enrolment_status,
'post_author' => $user_id,
'post_parent' => $course_id,
)
);
// Insert the post into the database
$isEnrolled = wp_insert_post( $enroll_data );
So I'm creating a query with WP_Query but how do I....I guess "customize" the array returned?
$query_args = array(
'author' => current_user_id(),
'post_type' => 'tutor_enrolled',
'post_status' => 'any',
);
// The Query
$the_query = new WP_Query( $query_args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
// I need to take post_parent
}
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
I need to get the post parent and look up that specific post and get the title and ID and somehow return that....maybe as post meta?
tutor_enrolled is just a "text string" meaning the Title is what happened for this data (ie. Course Enrolled). It doesnt have the actual course title or any course data.
I'm also trying to use all of this as a custom query in elementor so I can display the TutorLMS courses the current user is enrolled in.
Share Improve this question asked Feb 13, 2022 at 0:46 swg1cor14swg1cor14 1336 bronze badges 1- So did my answer help, or were you looking for something else? – Sally CJ Commented Feb 18, 2022 at 13:17
1 Answer
Reset to default 0and somehow return that....maybe as post meta?
I don't understand that