This code works, and I want to understand why.
So I created the object from the
WP_Query class, and used the
the_post() functions in a while loop.
The question is: since the
$post->ID is a data in an array based on the class
would this than mean that the object instantiated from the
WP_Post class is inside the object instantiated from the
Can an object be inside one another? Or am I missing something?
$the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : ?> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php echo '<p>' .$post->ID .'</p>';?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php else : ?> <p>No-data!</p> <?php endif; ?>