Support

Account

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