When your website means business.

ACF, CPT, WP Query | Type: PHPCPT to CPT Reverse Query

Reverse query from different post types associated via ACF relationship field.

$offices = get_posts(array(
	'post_type' => 'office',//other post type we're getting data from
	'meta_query' => array(
		'key' => 'personnel', //name of custom field from above post type
		'value' => '"' . get_the_ID() . '"',
		'compare' => 'LIKE'
<?php if( $offices ): ?>
<?php foreach( $offices as $office ): ?>
	<p><a href="<?php echo get_permalink( $office->ID ); ?>">
	<?php echo get_the_title( $office->ID ); ?>
	<?php endforeach; ?>
<?php endif; ?>

Reference Links

We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.