I'm a relative noob trying to filter post content selectively.
In my installation, only posts in one category include the custom fields "sponsor text" and "sponsor link".
If I create a custom category loop by category, the custom fields do not show up in single posts; if I apply it globally, then the special div to hold the meta data appears on ALL posts, even where the custom field data doesn't exist.
Here is the global function:
// Custom Category Loop
function remove_category_loop(){ // first remove the thematic action
remove_action('thematic_categoryloop', 'thematic_category_loop');
remove_action('thematic_archiveloop', 'thematic_archive_loop');
}
add_action('init','remove_category_loop');
function child_category_loop() { // now rebuild your version of the action
while (have_posts()) : the_post();
global $post;
$sponsortext = get_post_meta($post->ID , 'sponsor', true);
$sponsorlink = get_post_meta($post->ID , 'sponsorlink', true);
?>
<div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>">
<?php thematic_postheader(); ?>
<div class="entry-content">
<?php thematic_content(); ?>
<div id="sponsor">
<p><?php echo $sponsortext; ?></p>
<p>For more information visit the website, <a href="http://<?php echo $sponsorlink; ?>" target="_blank">http://<?php echo $sponsorlink; ?></a></p>
</div>
</div>
<?php thematic_postfooter(); ?>
</div><!-- .post -->
<?php endwhile;
}
add_action('thematic_categoryloop', 'child_category_loop');
add_action('thematic_archiveloop', 'child_category_loop');
This code works great for the one category page, http://seacliffmm.com/prod/centurion/category/clients-testimonials/,
But not for the general blog category page, http://seacliffmm.com/prod/centurion/category/news/
I'm sure the answer is an if-else construction,but so far I haven't been able to code one that works.
Please advise, if possible.