Home › Forums › General Issues › Relationship Post Object / Post ID › Reply To: Relationship Post Object / Post ID
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(
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 ): ?>
<table>
<thead>
<tr>
<th class="content-pad">Date</th>
<th>Time</th>
<th>Spaces</th>
<th>Price</th>
<th>Book</th>
</tr>
</thead>
<tbody>
<?php foreach( $date as $dates ):
$spacesleft = get_field('spaces',$dates->ID);?>
<tr>
<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; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.