How to display the latest entries on a separate page in wordpress?
1 answer
This code will display the last 5 posts
<?php $args = array( 'posts_per_page' => 5 ); $lastposts = get_posts( $args ); foreach( $lastposts as $post ){ setup_postdata($post); // устанавливаем данные ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> <?php } wp_reset_postdata(); // сброс ?>
Full documentation on get_posts (); Here http://wp-kama.ru/function/get_posts
|