Hello All,
I need help with a custom page template for displaying all posts in a certain category underneath the page content. I have the code 90% working but one little bug eludes me.
Page is drawing the category from a custom field "showcategory" whose string value should match the post category to be displayed on the page.
What I have:
...normal page template...
<!-- article-content -->
<?php if (is_search()) the_excerpt(); else the_content(__('Read the rest of this entry »', 'kubrick')); ?>
<?php if (is_page() or is_single()) wp_link_pages(array('before' => '<p>Pages: ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<!-- Display all posts of category set by post custom value key "showcategory" -->
<!-- Segment 1: Get custom value and assign to $catstubs -->
<?php $catstubs = get_post_custom_values('showcategory'); ?>
<?php echo "Category: $catstubs[0]";
$currentcat = $catstubs[0];
if (is_string($currentcat)) {
}
else { echo "it's not a string"; }
?>
<!-- Segment 2: display all post (title permalink and except) for $catstub category -->
<?php $myposts = get_posts('category_name=$currentcat');
foreach($myposts as $post) :
setup_postdata($post); ?>
<div class="art-post"><?php the_excerpt(); ?></div>
<?php endforeach; ?>
<!-- -->
<!-- /article-content -->
..continue normal template...
I'm getting a blank page when the category_name param is drawing from a variable.
Any help would be greatly appreciated!
Thanks!