Put recent post above comment box
-
I am trying to display the latest post in a category before the comments area. It seems the variable $post is grabbing the the_post data from the get_posts query that is grabbing the latest posts instead of the_post from the actual post which is expected. Any know how I can fix this.
The code below.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2 class="postheader"><?php the_title(); ?></h2> <span class="post-info">Posted <?php the_time('F jS Y') ?> at <?php the_time() ?> by <?php the_author() ?> </span> <span class="post-info"><?php edit_post_link('Edit', ' | ', ' '); ?> </span> <div class="entry"> <?php the_content('<p class="serif">Read the rest of this entry <img src="'.$path.'right.png" alt=">>" style="border:0;vertical-align:middle;padding-left:5px;" /></p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div> <div class="divider clear"></div> <span class="postmetadata"> <?php if (get_the_tags()) {the_tags( 'Tags: ', ', ', '<br /> ');} //make sure there's no line break if the post doesn't have tags?> Posted in <?php the_category(', ') ?> </span> </div> <?php endwhile; ?> <?php query_posts('cat=4&showposts=5'); if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h3> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?> </a></h3> <span class="post-info">Written on <?php the_time('F j, Y'); ?>at <?php the_time('g:i a'); ?>PST - By <?php the_author() ?></span> </div> <?php endwhile; ?> <?php endif; ?> <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) { // Both Comments and Pings are open ?> Follow comments via <?php post_comments_feed_link('RSS 2.0'); ?> feed. <!--You can <a href="#respond">leave a response</a>,--> Create a <a href="<?php trackback_url(); ?>" rel="trackback" title="Trackback URL: <?php trackback_url(); ?>">trackback</a> from your own site. <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) { // Only Pings are Open ?> <br />Responses are currently closed, but you can post a <a href="<?php trackback_url(); ?> " rel="trackback" title="Trackback URL: <?php trackback_url(); ?>">trackback</a> from your own site. <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) { // Comments are open, Pings are not ?> You can follow any responses to this entry through the <?php post_comments_feed_link('RSS 2.0'); ?> feed. <br />You can skip to the end and leave a response. Pinging is currently not allowed. <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) { // Neither Comments, nor Pings are open ?> <br />Both comments and pings are currently closed. <?php } ?> </p> <?php comments_template(); ?> <?php else: ?> <h2 class="center not-found">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; ?>
(if this doesn’t make sense let me know I will try to make it clearer)
- The topic ‘Put recent post above comment box’ is closed to new replies.