WordPress.org

Ready to get started?Download WordPress

Forums

Custom Fields to display a unique picture per page. (2 posts)

  1. tbresch
    Member
    Posted 6 years ago #

    I am a noob. I know very little about PHP.

    I want to display a unique picture per page using custom fields.

    I've modified the FallSeason 1.0 template intending to display a unique picture for each page in the sidebar div. I have the image I want to use in the theme's image folder.

    With success, I've used <?php the_meta(); ?> to display the meta data for my image. Very Cool.

    I've picked another piece of code from another discussion and am only able to display an image place-holder. Here's the code...

    <div id="sidebar">
    <img src="http://www.breschcraft.com/gorges/wp-content/themes/fallseason-10/images
    <?php $values = get_post_custom_values("sidebar_page_img"); echo $values[0]; ?>.jpg">
    </div>

    I'm closer than ever, but I need your help!
    Will you accept this challenge?

    Thanks very much.

  2. negs
    Member
    Posted 6 years ago #

    I'm having the same problem. I was doing it slightly differently, we are both doing the same thing where we are trying to replace the name of an image with a php result.

    <?php
    $pagepic = bloginfo ( 'stylesheet_directory' ).'/images/';
    
    if (is_page('us')) $pagepic .= 'us.png';
    
     ?>
    
    <img src="<?php echo $pagepic; ?>" alt="us" width="208px" height="160px" />

    But, it is NOT working. First it echos my stylesheet directory and then it prints the alt tag of the image.

    Anyway, If someone can solve tbresch's problem, I'll happily use that solution. Anyone out there?

Topic Closed

This topic has been closed to new replies.

About this Topic