WordPress.org

Ready to get started?Download WordPress

Forums

Show From Multiple Categories (1 post)

  1. Asif Mushtaq
    Member
    Posted 12 months ago #

    I am using this code to show Posts from the specific category ID = 47 I want to show Post from multiple categories like 47, 45 etc. How..? I try this 'cat' => 47,48, but failed. Any other solution..?

    <?php
    //display 10 posts for category id 47
        $args=array(
          'cat' => 47,
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => 10,
          'caller_get_posts'=> 1
          );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo 'List of Posts';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
          endwhile;
        }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Reply

You must log in to post.

About this Topic