I'm trying to display the two recent posts in a bloc I created in a front page of my website.
<div id="blog"> <h1> Post title 1 </h1> <p> Description </p> <button> Read More </button> <h1> Post title 2 </h1> <p> Description </p> <button> Read More </button> </div>
I want that the
Post title 1 and
Description of each post will be updated automatically when the admin add a new post and the recent post will be displayed on the front page.
I installed the insert php to add php code in a html page, then I wrote this snippet of code to test if I'm able to get the posts from the blog:
[insert_php] if ( have_posts() ) : while ( have_posts() ) : the_post(); echo "test successful"; endwhile; else : echo wpautop( 'Sorry, no posts were found' ); endif; [/insert_php]
But I got
Sorry, no posts were found however I had some posts in the blog page of my website.How can I fix that to display the latest recent posts in my front page?