• product247

    (@product247)


    I need to display custom field data from all subpages of a parent page in the loop. Here is the code to display all of the featured thumbnail images of subpages in the loop. But I need to convert this code to display a custom field variable instead. Can anyone help me with this? Here is the featured thumbnail code below:

    <?php query_posts(array('post_parent' => 19, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
                <?php if ( has_post_thumbnail() ) {?>
                    <?php the_post_thumbnail(); ?>
                <?php } else { ?>
                    <!-- Else Don't show anything -->
                <?php } ?>
        <?php } ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael

    (@alchymyth)

    The short answer:
    <?php echo get_post_meta($post->ID,’custom-field-name’,true) ?>

    🙂

    Thread Starter product247

    (@product247)

    Here is what I did so far:

    <?php query_posts(array('post_parent' => 19, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
        <a href='<?php the_permalink() ?>' rel="bookmark">
           <li class="menuItem"><img src="<?php echo get_post_meta($post->ID, 'navigation_thumbnail', true) ?>" alt="<?php the_title(); ?>" />
        </a></li>
        <?php } ?>

    It is pulling the sub categories and displaying the alt text but when I view the source the image location is empty. Could you tell me what I am doing wrong? Thank You

    Thread Starter product247

    (@product247)

    Actually I realized that the above code works.. Thanks Guys!!!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Display Custom Field Data In Loop’ is closed to new replies.