Home Forums General Issues Relationship Post Object / Post ID


Relationship Post Object / Post ID

  • Hello,

    I have setup a relationship field setup. The relationship is courses to course-dates

    I would like to use both the Title and the post ID of the parent course when listing the course dates how can I do this? for example

    Course Title | Course ID | Date | Price

  • Hello,

    Ive tried that but have been unable to show the results nothing appears for the title

    						$date = get_posts(array(
    							'post_type' => 'course-dates',
    							'meta_query' => array(
    									'key' => 'course', // name of custom field
    									'value' => '"' . $course_id . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
    									'compare' => 'LIKE'
    						<?php if( $date ): ?>
    										<th class="content-pad">Date</th>
    							<?php foreach( $date as $dates ): 
    							$spacesleft = get_field('spaces',$dates->ID);?>
    									<td class="content-pad"><?php the_field('startdate',$dates->ID);?>
    									<?php $course_title = get_field('course');
    						<?php if( $course_title ): ?>
    							<?php foreach( $course_title as $course ): ?>
    										<?php echo get_the_title( $course->ID ); ?>
    							<?php endforeach; ?>
    						<?php endif; ?>
  • Hi @joni

    Could you please share the JSON or XML export file of your field group so I can test it out on my end? Also, could you please tell me where you want it to show up? Is it on the course page or the course-dates page?

    Thanks 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Relationship Post Object / Post ID’ is closed to new replies.