Hi guys, I have searched and googled but I couldn't figure out how to make an image custom field works in my page. I have added different codes and it doesn’t work or it adds the URL if it was a text instead of adding the image. I want to add images to my page using Custom Fields. Not a loop, just a simple single image. I am new to WordPress and not good at all in PHP. I am just taking over a website that is published already.
Here it is my page template (I have 2 custom fields set up already: rss and extra):
<?php get_header(); ?>
<div id="content">
<?
$toplevelid = $post->ID;
if ($post->post_parent)
{
$toplevelid = $post->post_parent;
$toplevel = get_page($toplevelid);
if($toplevel->post_parent)
{
$toplevelid = $toplevel->post_parent;
}
}
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h1 class="page-title"><span class="page-title-span"><?php the_title(); ?></span><span class="title"><?php echo get_the_title($toplevelid); ?></span></h1>
<div class="entry">
<?php $key="extra"; echo get_post_meta($post->ID, $key, true); ?>
<?php
$key="rss";
$feedURL = get_post_meta($post->ID, $key, true);
if ($feedURL) {
$feed = new SimplePie($feedURL);
$item = $feed->get_item();
print $item->get_content();
} ?>
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
<?php wp_link_pages(array('before' => '<p>Pages: ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div><!-- close .entry -->
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div><!-- close .post -->
</div>
</div><!-- close #content -->
<?php get_footer(); ?>