• Hello,

    I am wanting to use a couple custom fields for each post that I do, the first being an ‘splash’ image of sorts or header for that particular post ( an image I upload, that appears above the title, date etc.) and a second for references that I used in my post that appears at the end of my post (this one appears to be more straight forward), but I am not finding anywhere that shows how to specify a particular image for a custom field.

    I am sure I am missing something. Thanks, j.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi – just putting the URL of an image in a custom field is not enough to get that image to display. Your theme template files have to be modified to retrieve the URL from the custom field, and then to display it.

    Its likely there are plugins that will do some of that, though I don’t know of any specific one. Otherwise it will require a few lines of customized PHP code.

    Having said that, what help from someone here would you find useful?

    What I do is change the WP upload folder to not use datebased folders… then on each post add a custom field called ‘Image’ and in the value I put ‘imgname.jpg’ or whatever…

    Then I use this:

    <?php $imgtxt = get_post_custom_values("Image Title"); $values = get_post_custom_values("Image"); if ( $values != '' ) { ?>
    <a href="<?php echo get_option('home'); ?>/wp-content/uploads/<?php echo $values[0]; ?>" rel="lightbox" title="<?php if( $imgtxt != '' ) { echo $imgtxt[0];} ?>"><img src="<?php echo get_option('home'); ?>/wp-content/uploads/<?php echo $values[0]; ?>" alt="<?php if( $imgtxt != '' ) { echo $imgtxt[0];} ?>" title="<?php if( $imgtxt != '' ) { echo $imgtxt[0];} ?>" /></a><?php } ?>
    
    <?php the_content(); ?>

    That way if you don’t enter a custom field for Image, nothing will show.

    othellobloke
    Thanks mate. helped me ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘image in custom field’ is closed to new replies.