WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Custom Field Template] Custom fields show the same values for all my posts (3 posts)

  1. krystiank
    Member
    Posted 4 years ago #

    I set up a Custom field template for one category only.

    When I list all my posts with the Custom Fields, Custom fields show the same values for all my posts.

    What am I doing wrong?

    Here is my Loop:

    <?php query_posts($query_string . '&cat=24'); ?>
     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
       	    <?php the_title(); ?>
    		Price: <?php echo $price; ?> | Apt. Size: <?php echo $apts; ?> | Location: <?php echo $loc; ?>
    		<?php the_content(); ?>
    <?php endwhile; ?>
     <?php endif; ?>

    Price, Apt size and Location are all the same for all my posts.

    http://wordpress.org/extend/plugins/custom-field-template/

  2. MichaelH
    Member
    Posted 4 years ago #

    Change:

    <?php echo $price; ?>

    to

    <?php echo get_post_meta($post->ID, 'price', true); ?>

    and a similar thing for the other two

  3. krystiank
    Member
    Posted 4 years ago #

    Thanks so much, it works now.

    I forgot to mention before that I used following to call my variables in echo

    <?php $apts = get_post_meta($post->ID, 'Apartment Size', true); ?>
    <?php $loc = get_post_meta($post->ID, 'Location', true); ?>
    <?php $price = get_post_meta($post->ID, 'Price', true); ?>

    But I took your advice and it works for me perfect.

    Thank so much for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.