Display category name
-
Hi!
I want to display the latest posts on my frontpage (non-wordpress). I did this by using:
<?php
$args = array( ‘numberposts’ => ‘7’ );
$recent_posts = wp_get_recent_posts();
foreach( $recent_posts as $recent ){
echo ‘<li class=”icon ‘ . $recent[“post_category”].'”><h3>’ . $recent[“post_date”].'</h3></ br><p>’ . $recent[“post_title”].'</p> ‘;
}
?>When I open the bron code of my page, I see:
<li class=”icon “><h3>2015-05-10 10:36:11</h3></ br><p> Test post</p> <li class=”icon “><h3>2015-05-10 08:48:26</h3></ br><p> Hello world!</p>
So that’s works!
But I want to add the category name (class=”icon category”). Is there any way to do this?
Hope you can help me out!
Thanks!
Meindert
The topic ‘Display category name’ is closed to new replies.