WordPress.org

Support

Support » How-To and Troubleshooting » Can You Manually Enter a "Featured Image" with "Custom Fields"

Can You Manually Enter a "Featured Image" with "Custom Fields"

  • I know there is a “Featured Image” function in the editor, but I am trying to do something a little different, and it won’t let me use that feature. (It’s complicated, so I won’t go into it here.)

    Is there a way to still use the “Featured Image” function via “Custom Fields”? … What would be the name to call the “Featured Image” function?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    @alchymyth

    Forum Moderator

    What would be the name to call the “Featured Image” function?

    there is no such a function.

    when you use a custom field for your feature image, you would need to edit index.php (and/or single.php – depending where you want to show the image) and insert something like the following, where you want the image to show:

    <?php $feature_img = get_post_meta($post->ID,'feature',true);
    if($feature_img) { ?>
    <img class="featured" src="<?php echo $feature_img; ?>" alt="" />
    <?php } ?>

    the if statement prevents an empty img tag if the custom field is empty.
    maybe with some html around, and styled in style.css.
    assuming that the $key for the custom field is ‘feature’ and the value is the absolute image url (including http://)

    OK, thanks. I’ll see if I can play with that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can You Manually Enter a "Featured Image" with "Custom Fields"’ is closed to new replies.
Skip to toolbar