Display First/Last Post from each Categories in wordpress -


i'm new wordpress. need display first/last post each parent categories. may in sub-category.

i need simple code that.

thanks.

<?php $category = get_categories(); foreach ($category $cat) {     query_posts( array ( 'cat' => $cat->cat_id, 'posts_per_page' => 5 ) );     echo '<div class="post">';     echo '<h2>'.$cat->cat_name.'</h2>';     echo '<ul>';     while (have_posts())     {         the_post();         echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';     }     echo '</ul>';     $category_id = get_cat_id($cat->cat_name);     $category_link = get_category_link($category_id);     echo '<div class="paging">';     echo '<a href="'.$category_link.'" title="'.$cat->cat_name.'">more post '.$cat->cat_name.'</a>';     echo '</div>';     echo '</div>'; } ?> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -