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βre excited to announce we've released Composer support for installing ACF PRO.
— Advanced Custom Fields (@wp_acf) January 31, 2023
π #ComposerPHP fans rejoice!
β¨ Please see the release post for all the details and full instructions. https://t.co/ebEfp61nlR
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.