Forums

Custom Fields - problems displaying individual keys (2 posts)

  1. maxcap
    Member
    Posted 9 months ago #

    Hi

    I want to be able to display individual values of keys within a post, but am having problems doing so. I've tried all the variations available on this forum.

    Key: client
    Value: Joe Blogg

    The code I am using is:

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

    However, nothing is displayed in the post.

    When I use to test:
    <?php the_meta(); ?>

    It works fine, displaying "client: Joe Bloggs", but this isn't what I need (I only need the value). The code is absolutely positively within the loop.

    Can anybody help? I've exhausted my limited knowledge of PHP!
    Thanks, Max

  2. MichaelH
    moderator
    Posted 9 months ago #

    This works for me:

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

Reply

You must log in to post.

About this Topic