Home › Forums › General Issues › Getting custom field from related post type › Reply To: Getting custom field from related post type
I’ve used the following:
<?php
$job_client_connect = get_posts(array(
'post_type' => 'people',
'meta_query' => array(
array(
'key' => 'job_client', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
?>
<?php if( $job_client_connect ): ?>
<table>
<?php foreach( $job_client_connect as $job_client_connect ):?>
<tr>
<td>
<a href="<?php echo get_permalink( $job_client_connect->ID ); ?>">
<?php echo get_the_title( $job_client_connect->ID ); ?>
</a>
<p><?php echo get_field('employer', $job_client_connect->ID ); ?></p>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
Displays the name & permalink, still not getting the employer ACF info though. It just prints Array below
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.