How to display posts in the wordpress front page

I searched on internet for different solution, then I found one pleasant for my website. First of all I modified the style.css file to define a nice list in HTML.

#MyList {
    margin-bottom: 20px;
}

the I added the following PHP code in front-page.php:

<center><h2><font color=#051A23>RECENT POSTS ... </font></h2>
<br> 
<ul id="MyList">
<?php query_posts('showposts=3'); ?> 
<?php while (have_posts()) : the_post(); ?> 
<li id="MyList">
<h2><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2><br>
<div id="col_one_inverse">
<?php 
if ( has_post_thumbnail() ) {  
echo '<img src="'.wp_get_attachment_image_src( get_post_thumbnail_id())[0].'" width=150>';
        } ?></div>
    <div id="col_two_inverse"><br><?php the_excerpt(__('(more…)')); ?></div>
    <br style="clear: both;" />
    </li>
<?php endwhile;?>
</ul>
</center>

and that’s all, the result on my webpage: http://attaccalite.com.

Leave a Reply

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