on this page i have the code below to pull in the two most recent posts. however for some reason, the date it says below the title is January 20, 2011 for both posts event though they both have two different "Published Dates" than that. why's this happening??? <h2>The Latest at Cornerstone</h2> <?php $latestposts = get_posts('numberposts=2&category=1'); foreach($latestposts as $post) : setup_postdata($post); ?> <h3><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></h3> <h6><?php the_date(); ?></h6> <?php the_content(); ?> <?php endforeach; ?> PHP:
Not sure, the_date() has a strange rule about only being used once. Try using <?php the_time('F j, Y'); ?>, or try <?php echo get_the_date(); ?> if that does not work.
this seems to be working, though the post titles have now disappeard: <?php $custom_query = new WP_Query( 'posts_per_page=2&cat=1' ); if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?> <h3><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></h3> <h6><?php the_time('F j, Y') ?></h6> <?php the_content(); ?> <?php endwhile; else : ?> <h3>Sorry...</h3> <p>No posts were found.</p> <?php endif; ?> Code (markup): any idea how to get these post titles, which you can see here, to show??
actually this seems to be working: <?php $custom_query = new WP_Query( 'posts_per_page=2&cat=1' ); if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?> <h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </h3> <h6><?php the_time('F j, Y') ?></h6> <?php the_content(); ?> <?php endwhile; else : ?> <h3>Sorry...</h3> <p>No posts were found.</p> <?php endif; ?> Code (markup):