WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show posts from two categories - list by post date (2 posts)

  1. venkmanuk
    Member
    Posted 1 year ago #

    hi there..

    I'm trying to show posts from two categories, and have them display in the traditional blog manner, most recent first.

    Problem is that no matter what date the cat 11 posts were created, category 12 posts appear above category 11.

    Any ideas why this might be?

    if ( is_page( 'news-and-events' ) ) {
    
    			//for categories 11,12 show 10 posts
    			$cat_args=array(
    			  'include' => '11,12',
    			  'orderby' => 'post_date',
    			  'order' => 'ASC'
    			   );
    			$categories=get_categories($cat_args);
    			  foreach($categories as $category) {
    				$args=array(
    				  'showposts' => 10,
    				  'category__in' => array($category->term_id),
    				  'caller_get_posts'=>1
    				);
    				$posts=get_posts($args);
    				  if ($posts) { 
    
    					foreach($posts as $post) {
    					  setup_postdata($post); ?>
  2. venkmanuk
    Member
    Posted 1 year ago #

    just do it this way:

    if ( is_page( 'news-and-events' ) ) {
    			query_posts( 'cat=11,12' );
    			while ( have_posts() ) : the_post();

Topic Closed

This topic has been closed to new replies.

About this Topic