upekshapriya
Member
Posted 3 years ago #
I'm wanting to start a new loop within a plugin (to be brief) and I've tried using $new_query = new WP_Query but I find that the result array I am getting is empty of values (I've checked it with print_r() and found that only the keys are there).
Is what I am wanting to do possible? And if so am I missing a global variable of some sort?
I found a similar problem writing a widget plugin.
I was using this structrure:
<?php $my_query = new WP_Query('category_name=featured&showposts=1');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<!-- Do stuff... -->
<?php endwhile; ?>
I found out that the proper values (the ones that you want to call in the Do stuff space) are not in $post but in $my_query->post. Maybe was it also your case?