Looping Through a 3D Post Array

Question

I’ve managed to generate a post array which combines output from two different queries.

Array
(
    [0] => Array
        (
            [0] => WP_Post Object
                (
                    [ID] => 17636
                    [post_author] => 1
                    [post_date] => 2020-08-04 10:14:06
                    [post_date_gmt] => 2020-08-04 10:14:06
                )

            [1] => WP_Post Object
                (
                    [ID] => 17634
                    [post_author] => 1
                    [post_date] => 2020-08-04 10:14:06
                    [post_date_gmt] => 2020-08-04 10:14:06
                )

            [2] => WP_Post Object
                (
                    [ID] => 17635
                    [post_author] => 1
                    [post_date] => 2020-08-04 10:14:06
                    [post_date_gmt] => 2020-08-04 10:14:06
                )

        )

    [1] => Array
        (
            [0] => WP_Post Object
                (
                    [ID] => 17761
                    [post_author] => 1
                    [post_date] => 2020-08-04 10:15:07
                    [post_date_gmt] => 2020-08-04 10:15:07
                )

        )

)

When I try to loop through it to get the IDs of each post, it outputs blank because I don’t know how to access the layer above iteratively. What code should I use to grab the IDs inside a foreach loop?

Or can I apply something to the original array to remove the non-required first level?

0
user3798168 3 months 0 Answers 11 views 0

Leave an answer