Querying post relationships in reverse direction when using Advanced Custom Fields plugin on WordPress
<?php | |
$tour_pages = get_posts( | |
array( | |
'post_type' => 'tour', | |
'meta_query' => array( | |
array( | |
'key' => 'tour_author_relationship', // name of custom field | |
'value' => '"' . get_the_ID() . '"', | |
'compare' => 'LIKE' | |
) | |
) | |
) | |
); | |
if ( ! empty( $tour_pages ) ) { | |
echo '<a href="' . get_permalink( $tour_pages[0]->ID ) . '">Author on Tour</a>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
This is exactly what I needed. Thank you.