php - Require One Post per Category in Wordpress -


i have created website in wordpress... , requirement need 1 post per category on homepage..

below code in php:

$args = array('type' => 'post', 'orderby'  => 'name', 'order' => 'asc', 'number' => '10', 'taxonomy'  => 'category'); $categories = get_categories($args);  foreach($categories $category) {     $catquery = new wp_query( 'cat='.$category->cat_id.'&order=desc' );      while($catquery->have_posts()) : $catquery->the_post();       echo "some div & links";     endwhile;   } 

the above code give me post in category... how 1 latest post per category..??

wat should change in above code..??? please let me know...

i have resolved issue.. please check below code

$args = array('type' => 'post', 'orderby'  => 'name', 'order' => 'asc',  'number' => '10', 'taxonomy'  => 'category'); $categories = get_categories($args);  foreach($categories $category) {    $catquery = new wp_query( 'cat='.$category->cat_id.'&order=desc' );     $catquery->the_post();     echo "some div & links";      } 

i removed while loop...:)


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -