• lilqhgal

    (@lilqhgal)


    I have a snippet of code that I would like to display ONE post’s title and date. Nothing else. I want to place this in the header. I want it so that it displays the next upcoming post. I can’t seem to get it to work. My category page has a loop so I’m not sure if I can put a loop in the header? Any ideas? Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter lilqhgal

    (@lilqhgal)

    WOW I feel so ACCOMPLISHED!

    I’m NOT a programmer, so please let me know if this code isn’t good in any sort of way! But here’s what I finally worked up that seems to be working for me:

    <?php if (is_front_page())  { ?>
    	<?php $catposts = get_posts('numberposts=1&category=5&post_status=future&orderby=date&order=asc'); foreach($catposts as $post) : ?>
    		<div id="categoryposts-4" class="widgets_top"><h3>Our Next Show</h3>
    		<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?> - <?php the_date(); ?></a></p>
    		</div>
    	<?php endforeach; ?>
    	<?php } ?>

    Note: in my case, I was getting posts from category 5, only displaying those that are “future” based on WP’s “scheduled” status. Hope it helps someone else!

Viewing 1 replies (of 1 total)
  • The topic ‘Display one post title & date in header?’ is closed to new replies.