Support

Account

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[0]; // 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:

    get_field('my_post_field', $desired_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