wp_query omitting posts and returning duplicates.
-
I’m not sure what’s going on here.
This is my code:
$events=new WP_Query( array('post_type'=>'team_list_event') ); if($events->have_posts()){ while($events->have_posts()){ $QID=$events->post->ID; echo ' <tr><td> <a href="">'.get_the_title($QID).'</a> </td></tr>'; $events->the_post(); $i=($i==0)?1:0; } echo '</table>'; }
I have 2 posts, ID 6 and ID 22.
ID 6 is skipped and ID 22 is rendered twice.
I’ve obviously misunderstood how the loop works: what am I doing wrong?
I suppose I could set up a query “SELECT
ID
,post_type
FROMwp_posts
WHEREpost_type
= ‘team_list_event'”, but I want to do it the proper way.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘wp_query omitting posts and returning duplicates.’ is closed to new replies.