Outputting custom fields in index.php and category.php (2 posts)

  1. marc0047
    Posted 9 years ago #

    I've always had success outputting custom fields in individual posts via the single.php template.

    However, I'm trying to output custom fields for multiple database entries in the index.php, home.php, and category.php templates without much luck. Nothing gets outputted when I implement it this way:

    <?php $product_thumb1 = get_post_meta($post->ID, 'product_thumb1', 1); ?>
    <?php if (have_posts()) : ?>
    <?php query_posts('cat=12&showposts6'); ?>
    <?php while (have_posts() ) : the_post(); ?>
    <?php if($product_thumb1) { print $product_thumb1 } ?>
    <?php endwhile; ?>
    <?php endif; ?>

    Any clues?

  2. alakhnor
    Posted 9 years ago #

    I think you have to insert the get_post_meta inside the loop.

Topic Closed

This topic has been closed to new replies.

About this Topic