Vertical and Horzontal recent post list

This code will not require the wordpress recent post wedget.

you can copy and paste this code anywhere you like to put in the part of your website.

Recent post vertical list

code:

<ul>
<?php
$rand_posts = get_posts(‘numberposts=15′);
$i=0;
foreach( $rand_posts as $post ) :
$i++;
if ($i <= 15){
?>

<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>

<?php } endforeach; ?>

</ul>

Recent post horizontal list

code:

<?php
$rand_posts = get_posts(‘numberposts=4′);
$i=0;
foreach( $rand_posts as $post ) :
$i++;
if ($i == 1){
?>

<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>,

<?php } else { if ($i == 2) {?>

<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>,

<?php } else { if ($i == 3) {?>

<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>,

<?php } else {?>

<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>

<?php } } } endforeach; ?>

Tags: | No Comments »

Leave a Reply