Support » Fixing WordPress » Posts Order with Respect to Category

  • Resolved maddysayz


    Dears, I am developing this website and there is a requirement of having one most updated post from 6 categories displayed on home page. That functionality has been taken care of. The issue is the order in which the categories should be listed along with their one latest post. Can you help me out here please with it.

    the code that displays the 1 post per category is given below. The order in which category should appear is 9,14,10,16,15,13:

    foreach( array(9,14,10,16,15,13) as $cat_id ) {
    					if ( $posts = get_posts(array('category__in' => $cat_id, 'numberposts' => 1)) ) {
    							//echo $cat_id;
    							$first = array_shift($posts);
    							$post_ids[] = $first->ID;
    							//echo $cat_id."---".$first->ID."<br>";
    query_posts(array('post__in' => $post_ids));
    // loop
    while (have_posts()) : the_post();
    //whatever needs to be displayed

    Hope to have a reply ASAP.

    Thank you in Advance.



    [ – if it is that urgent, consider to hire somebody; ]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Posts Order with Respect to Category’ is closed to new replies.