How to Display All Recent Post In a Page or Post in wordpress?
WordPress is being popular these days and adored by several developers. It's simple for articles updating too. Do you want to show your current posts in wp? Exhibiting current posts helps your users locate them easily.
In this tutorial, we'll explain to you the best way to show current articles in WordPress without a plugin the manual process with the post use is recent. So that people are able to cut the external link obtain, it's almost always easier to take action without plug-in.
Displaying Recent Posts in WordPress
<?php $recent_posts = wp_get_recent_posts(); foreach( $recent_posts as $recent ){ echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"].'</a> </li> '; } wp_reset_query(); ?>
To get date of post when using wp_recent_post(), the following code display latest post title as well as date in the same line.
<?php
$recent_posts = wp_get_recent_posts();
foreach( $recent_posts as $recent ){
echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"]. $recent["post_date"].'</a> </li> ';
}
wp_reset_query();
?>
To display the certain number of posts only
$args = array( 'numberposts' => '2' );
$recent_posts = wp_get_recent_posts( $args );