Trying to display latest posts
-
Hi all,
I’m trying to display the prior two posts on my main page, but I’m not getting anywhere with this code. Can anyone tell me what I am doing wrong in this code? I show no syntax errors on Dreamweaver, but I get nothing.
My ultimate goal is to display a section with the latest article, then display the previous 2 articles in another section of the page. I decided to start with the previous 2 articles first just to make sure offset was working.
<ul> <?php $args = array( 'numberposts' => '2', 'offset' => 1 ); $recent_posts = wp_get_recent_posts( $args ); if( $recent_posts->have_posts() ) : while( $recent_posts->have_posts() ) : $recent_posts->the_post(); echo "<li class='postWrapper'> <div class='featured_image'><a href=". the_permalink(). "rel='bookmark'>" . the_post_thumbnail('thumbnail') . "</a></div> <div class='post_content'> <h2 class='postTitle'><a href=" . the_permalink() . "rel='bookmark'>" . the_title() . "</a></h2> <div class='post'>" . the_content(__('(more...)')) . "</div> <div class='readmore'><a href=". the_permalink() . " rel='bookmark'>Read More...</a></div> </div> <hr class='post_divider' /> </li>"; endwhile; endif; wp_reset_postdata(); ?> </ul>
Any help would be greatly appreciated.
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘Trying to display latest posts’ is closed to new replies.