Home › Forums › General Issues › How to display a wp post from a custom field trigger in custom posts (events) › Reply To: How to display a wp post from a custom field trigger in custom posts (events)
If you’ve selected ‘Post IDs’ as the return format for your Relationship field, then
get_field('page_link') (for example) will return an array of post IDs. If you clamp them down to just choosing ONE (by setting the Maximum Posts’ value to 1), then you can safely get your post ID by doing something like:
$linked_post_ids_array = get_field('page_link'); // gets the array post post IDs $desired_post_id = $linked_post_ids_array; // gets the ID of the 1st item in the array
once you have the post ID, you can use a variety of WordPress and ACF functions to get related content,
i.e. for an ACF field connected to the post, just pass the post ID:
for general post info, you can use WordPress’ get_post
$post_object = get_post($desired_post_id);
hope this is enough info to point you in the right direction
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!