I am trying to display the all post in table With my plugin . I already have three post but following code doesn’t display anyting .
CODE OF PLUGIN PAGE :
<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
<tr>
<td id="username"><?php the_title(); ?></td>
<td>
<video class="video" width="200" height="100">
<source src="<?php echo $rs->user->profile_video;?>" type="video/mp4">
Your browser does not support the video.
</video>
</td>
<td id="status"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"></a></td>
<td><select class="action">
<option>-Select-</option>
<option value="1" >Active</option>
<option value="0">Inactive</option>
<option value="edit">Edit</option>
<option value="4">Delete</option>
</select></td>
</tr>
<?php endwhile; ?>
<?php endif; ?>
Where I have done My Mistake ???
You can use WP_Query to retrieve your posts. WP_Query is a class and its constructor will return an object, which also has the loop functions.
Notice the
$wq
variable and$wq->have_posts()
, etc.Important: for the functions called inside the loop (
the_title()
,the_content()
,the_permalink()
, etc.) don’t prepend the$wq
variable. They work as they would withquery_posts()
I had the same problem,
when i used print_r($wq);
i got a result, but have_posts() returned false
i fixed it for me using following code: