CMS & WordPress
nicolanicola — 2012-03-28T15:44:53-04:00 — #1
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!
brynnae — 2012-04-05T08:53:30-04:00 — #2
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.
w1nk5 — 2012-04-05T19:58:49-04:00 — #3
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;?>
mittineague — 2014-09-22T05:15:06-04:00 — #4
This topic is now archived. It is frozen and cannot be changed in any way.