Forums

[resolved] Use Custom Fields on Pages? (2 posts)

  1. jasjoerii
    Member
    Posted 1 year ago #

    Hi guys,

    I've got a problem with using Custom Fields on a page. I'd like to show an image using a Custom field, but I can't get it to work. Do I have to do anything differtent then when I'm using it on a post? Can someone please help?

    Link: http://www.lemke.jasites.nl/?page_id=9 (yes i'm dutch)

    This is the code I use:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <div id="subimages">
    
                <img src="<?php get_post_meta($post->ID, 'img1', true); ?>" alt="" />
    
                <img src="<?php get_post_meta($post->ID, 'img2', true); ?>" alt="" />
    
            </div>
  2. jasjoerii
    Member
    Posted 1 year ago #

    I get it. I added "echo"

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <div id="subimages">
    
                <img src="<?php echo get_post_meta($post->ID, 'img1', true); ?>" alt="" />
    
                <img src="<?php echo get_post_meta($post->ID, 'img2', true); ?>" alt="" />
    
            </div>

Topic Closed

This topic has been closed to new replies.

About this Topic