Hello,
I am setting up a custom page template for which the background and content will be defined by the custom field values of the page using the template.
I am trying to generate 2 lists of posts, one from category A and the other from category B, the page's custom fields being "category" and "category-news" and the respective values being the category slugs.
I've gotten this far thanks to the WP Codex, but i can't get it to work with the second category :
<div id="page-items-list">
<ul>
<?php
if (is_page() ) {
$category = get_post_meta($posts[0]->ID, 'category', true);
}
if ($category) {
$cat = get_cat_ID($category);
$post_per_page = 18; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => array($cat),
'orderby' => 'date',
'order' => 'DESC',
'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(); ?>
<li><div style="float:left;margin-bottom:10px;"><div class="thumblist"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a></div></div>
</li>
<?php endwhile; ?>
</ul>
</div><!-- .page-items-list -->
<?php else : ?>
<h2 class="center">Not Found</h2>
<?php endif;
$wp_query = $temp; //reset back to original query
} // if ($category)
?>
If I copy this underneath and change get_post_meta($posts[0]->ID, 'category', true); to get_post_meta($posts[0]->ID, 'category-new', true); it doesn't find any posts...
What am I doing wrong here?
This may not be the smartest way to do this but my PHP skills are pretty weak so any help would be great.
Thank you,
C.