ACF – Get ID of relationship field in flexible content

Question

I’m trying to get ID from a relationship field within a flexible content and push it in a array

if (have_rows('studio_blocs')) {
    while(have_rows('studio_blocs')) {
        the_row();
        $news = get_sub_field('studio_bio_list');

        if ($news) {
            foreach($news as $item) {
                $array[] = $item;
            }
        }
    }
    print_r($array);
}

For the moment I got this output, can I have some help to get the ID and push it in my array please ?

Array
(
    [0] => 
    [1] => WP_Post Object
        (
            [ID] => 88
            [post_author] => 1
            [post_date] => 2019-11-07 14:52:40
            [post_date_gmt] => 2019-11-07 13:52:40
            [post_content] => 
            [post_title] => Sébastien Arkange
            [post_excerpt] => 
            [post_status] => publish
            [comment_status] => closed
            [ping_status] => closed
            [post_password] => 
            [post_name] => sebastien-arkange
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2019-11-07 14:53:27
            [post_modified_gmt] => 2019-11-07 13:53:27
            [post_content_filtered] => 
            [post_parent] => 0
            [guid] => http://dev.mywebsite.com/?post_type=collaborateurs&p=88
            [menu_order] => 8
            [post_type] => collaborateurs
            [post_mime_type] => 
            [comment_count] => 0
            [filter] => raw
        )

)
0
, , , Jandon 3 days 0 Answers 6 views 0

Thousands of WordPress themes to start your new website with a bang.

Leave an answer