Some category IDs don't pull posts, others do
-
I have programmed a loop in a custom page template that pulls the single latest post from 4 different categories on the site, in 4 separate divs. Works great for 3 of the categories, but when I plug in the category ID of the 4th, posts from another category will appear instead. There are posts published in the faulty category that I’m trying to pull. I created a new test category and placed a post there, but the same thing happens.
Here’s my code:
<div class="item"> <?php $args=array( 'cat' => 14, 'showposts' => 1, 'caller_get_posts' => 1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php if(has_post_thumbnail()): ?> <div class="visual-grid"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('grid_thumb'); ?></a> <div class="category-name"> <?php $category = get_the_category(); ?> <?php echo $category[0]->cat_name; ?> </div> </div>
Any insight on what the problem could be?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Some category IDs don't pull posts, others do’ is closed to new replies.