我想使用 wordpress 的自定义字段为我的网站设置不同的标题横幅,这是我的代码:
<?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(); ?>
现在代码呈现,但由于某种原因,它只将 img 路径呈现为:
<img alt="" src="http://www.testground.idghosting.com/philcom/wp-content/themes/phil"/>
这是演示站点
在自定义字段中,我输入了这个:image 对于我输入的值:/images/sampleHead.png