Best way to display posts from 3 different categories in one page

I’m wondering the best way to do this. I created a custom post and the custom post can have multiple categories. I have created a custom template and I’m wondering now the best way to go about getting the posts in. I don’t really understand the while loop e.g.

<?php while ( have_posts() ) : the_post(); ?>

, what posts is it on about? Can I give it those details, or is it better just to do:

$posts = get_posts(array(
            'numberposts'   => 5,
               'orderby'       => 'post_date',
               'order'         => 'DESC',
               'post_type'       => 'give',
               'post_status'     => 'publish' 

Wordpress absolute newbie by the way!

I think It won’t work for displaying 3 categories from three pages on a single page. I think you need to fetch details from all those 3 pages and join then using joins and then you can display on single page.

You can use the query_posts() function to change the loop; and use the ‘category__and’ parameter to specify which categories you want to include.

Simply assign an array of the category ID’s you want to include to ‘catergory__and’ and you’re ready to rock.


<?php query_posts( array( 'category__and' => array(1,3)); ?>

<?php if(have_posts()) : while(have_posts()) : the_post(); ?>

		Your content here.
			
<?php endwhile; endif;?>