[Resolved] WP_Query loop inside widget error
I’m having issues with a custom wp_query in the widget. This code works fine throughout my site:
<?php $facts = custom_wp_query('3'); //get 3 results //echo "<pre>"; print_r($facts); echo "</pre>"; while ( $facts->have_posts() ) : $facts->the_post(); echo "<pre>"; print_r($post); echo "</pre>";//This works elsewhere endwhile; ?>
The custom query gives me 3 wp_post objects in $facts as expected. However, the while loop fails saying $post is not defined. This works elsewhere on my site, but not in this widget. What am I missing?
- The topic ‘[Resolved] WP_Query loop inside widget error’ is closed to new replies.