Tag Info

Hot answers tagged

2

First of all post field of WP_Query is current post ID and not post object. But I don't think you should use it before calling the_post() method. Normally you should do it in this way: $args = ... $hometeams = new WP_Query( $args ); $teamishome = $hometeams->have_posts(); while ( $hometeams->have_posts() ) { $hometeams->the_post(); $scorehome ...


1

If you var_dump($hometeams); you will see that $hometeams->post is set to the first post in the query results even before $hometeams->the_post runs. WP_Query initializes it automatically if you have posts in the result set. The "Undefined Property" warning occurs when your result set is empty, and thus $hometeams->post can't be set/initialized. ...



Only top voted, non community-wiki answers of a minimum length are eligible