Wordpress Custom Field
Posted
by kwek-kwek
on Stack Overflow
See other posts from Stack Overflow
or by kwek-kwek
Published on 2010-03-26T19:27:52Z
Indexed on
2010/03/27
12:13 UTC
Read the original article
Hit count: 305
I wanted to use the custom field for wordpress to have a different header banner for my site here is my code:
<?php
get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="BodyWrap">
<!--MAIN CONT-->
<div id="mainCont">
<?php get_sidebar(); ?>
<div id="rotateBanner"><?php
// check for image
$image = get_post_meta($post->ID, 'image', $single = true);?>
<img class="mainImg" src="<?php bloginfo(template_url); echo $image; ?>" alt=""/>
</div>
<div id="mainCopy">
<div id="content">
<h2><?php single_post_title(); ?></h2>
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div>
</div>
</div>
</div>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
Now the code renders but for some reason it only renders the img path as:
<img alt="" src="http://www.testground.idghosting.com/philcom/wp-content/themes/phil"/>
here is the demosite
in the custom field I put this: image For the value I put this: /images/sampleHead.png
© Stack Overflow or respective owner