[resolved] Posts Older than 3 Days Not Showing (2 posts)

  1. JoE
    Posted 4 years ago #

    Alright, racked my brain on this one and I'm coming up short. Using a custom post type for the company's Government Affairs section. For some reason, posts older than 3 days will not show up. Recently tried resetting the query (even though it's the first one on the page). Any help would be amazing. Thanks.

    	if(is_page('Government Affairs')):
    			wp_reset_query(); // Reset Query
    			// Display Custom Post Type
    			$recent = new WP_Query('post_type=govt&posts_per_page=4'); $x=1;
    			while($recent->have_posts()) : $recent->the_post(); ?>
    				<?php $terms = get_the_terms($post->ID, 'govt-category');
    				foreach($terms as $item):
    					if($item->slug != "govt_affairs_updates"): ?>
    					<div class="post<?=($x%2 ? ' odd':' even')?>"><?php $x++;?>
    						<h4><a href="<?=the_permalink()?>"><?=the_title()?></a></h4>
    						<span class="author">Posted in <a href="#"><?=custom_post_taxonomy('govt-category')?></a> <?=relative_time()?></span>
    						<p><?=the_excerpt()?> <a href="<?=the_permalink()?>" class="more"><?=more_text()?></a></p>
    					<?php endif; ?>
    				<?php endforeach; ?>
    		<?php endwhile; ?>
    <?php endif; ?>
  2. JoE
    Posted 4 years ago #

    Got it! Turns out that the if statement, searching on the slug, was hitting posts that did not have a slug specified. The person entering the data did not choose a category for the custom post, so when the loop hit that line, it just crapped out because there was nothing.

    The if statement was wholly dependent on a value being passed, I should have had some checking in place to ensure there is indeed a value.

Topic Closed

This topic has been closed to new replies.

About this Topic