I have a strange situation.
I want to store the IDs from a wp_query in a variable.
So far i have the following:
$loop = new WP_Query( array(
'post_type' => 'programma',
'post_parent' => 0,
'posts_per_page' => -1,
) );
if ( $loop->have_posts() ):
while ( $loop->have_posts() ) : $loop->the_post();
$ids[] = get_the_ID();
Now the strange thing is: when i print_r($ids), i get the following:
Array ( [0] => 5404 )
Array ( [0] => 5404 [1] => 5307 )
Array ( [0] => 5404 [1] => 5307 [2] => 5308 )
Why is this? And how can i prevent this? I only want the last array to be stored.
var_dump)