Support

Account

Home Forums Backend Issues (wp-admin) modifying the post object return value on backend

Solved

modifying the post object return value on backend

  • Not even sure this is possible, but hoping someone can help…

    We’re building a site that is using the events calendar plugin to create events.

    I’ve created a repeater for pages that has a post object field set to events to allow us to select (and promote) an event on the page, which works fine.

    The problem is we have 3 venues, and for simplicity for the client, events are named by the date, so for example, 13 August 2023, but doesn’t refer to the venue.

    This means that if we have two dates, but different locations, it’s impossible to determine in the post object selector in the repeater what venue event you’re choosing.

    The event has a venue field you select, so it’s stored in the meta data.

    What I’d love to be able to do is modify the output in the post object dropdown to include the venue name – for example 13 August 2023 (venue A).

    Does anyone know if I’m chasing rainbows or if this is actually possible? I can’t find any links to help me figure it out.

    Thanks in advance

  • Actually found a solution and was so much easier than expected, if anyone else needs this…

    add_filter('acf/fields/post_object/result', 'my_post_object_result', 10, 4);
    function my_post_object_result( $text, $post, $field, $post_id ) {
    
        /* Get whatever value you want here e.g. */
        $text .= ' (' . tribe_get_venue($post->ID) .  ')';
    
        /* do any other processing you might want to do before returning it... */ 
    
        return $text;
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.