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 -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -