PHP – WordPress – List of Latest Posts

The given PHP example helps you display the list of latest news articles in WordPress.

Code Example:
<?php
function latest_news_list($count) {
?>
	<h3>latest news</h3>
    <ul>
    <?php
    global $post;
    $args = array( 'numberposts' => $count, 'offset'=> 0, 'category' => 1 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) : setup_postdata($post); ?>
    <!-- <p class="date"><?php the_date(); ?></p> -->
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    <?php
}
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *