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',
                                 '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() ) {
// I need to take post_parent
    /* Restore original Post Data */
} 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 did my answer help, or were you looking for something else?
    – Sally CJ
    Feb 18, 2022 at 13:17

1 Answer 1


and somehow return that....maybe as post meta?

I don't understand that 🤔, but you can use get_post_meta() to retrieve a post meta.

I need to get the post parent and look up that specific post and get the title and ID

As for the ID, that would be the post parent itself, but correct me if I'm wrong or that you meant something else?

As for getting the current post's parent and the parent post's title (and other data), you can use get_post_field() and get_post(), like so:

// Get the parent post ID.
$post_parent = get_post_field( 'post_parent' );
// Alternatively, you could add global $post; at the top in your code and just
// use $post->post_parent in your loop.

// Get the parent post object.
$parent_post = get_post( $post_parent );

// And display the parent post's title..
echo $parent_post->post_title;
// .. or use echo get_the_title( $parent_post )
  • PS: $post_parent = get_post()->post_parent; also works for getting the post parent.
    – Sally CJ
    Feb 13, 2022 at 4:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.