Hello!
I've implemented the Page of Posts example from the Codex's "Pages" page, and like it a great deal. However, I was wondering how can one make it so that multiple categories can show up, instead of just the one.
Here's the code:
<?php
if (is_page() ) {
$category = get_post_meta($posts[0]->ID, 'category', true);
}
if ($category) {
$cat = get_cat_ID($category);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = 4; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => array($cat),
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $post_per_page,
'caller_get_posts' => $do_not_show_stickies
);
$temp = $wp_query; // assign orginal query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
if( have_posts() ) :
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
I'm thinking there's probably a better way of doing it instead of using a custom field, and having very rudimentary php knowledge I'm not sure how to figure it out. I also don't mind hard-coding the Categories if need be, as the cats are few and there won't be many additions.
Any thoughts?