-4
我在自定义WP主题的标题中只在页面上(而不是帖子)显示图像横幅。我需要这个横幅在主页上有所不同。我创建了一个头版模板,有这样的:If/else在Wordpress中进行测试
<?php if (is_front_page()){ ?>
<div class="banner">
<?php if (get_header_image()) : ?>
<a href="<?php echo esc_url(home_url('/')); ?>" rel="home">
<img src="<?php header_image(); ?>" width="<?php echo esc_attr(get_custom_header()->width); ?>" height="<?php echo esc_attr(get_custom_header()->height); ?>" alt="">
</a>
</div><!-- #banner -->
<?php else { ?>
<div class="banner">
<?php if (get_header_image()) : ?>
<a href="<?php echo esc_url(home_url('/')); ?>" rel="home">
<img src="<?php header_image(); ?>" width="<?php echo esc_attr(get_custom_header()->width); ?>" height="<?php echo esc_attr(get_custom_header()->height); ?>" alt="">
</a>
<?php endif; // End header image check. ?>
</div><!-- #banner -->
我使用的是相同的图像两次在这里只是为了测试,但得到错误的堆。我的PHP不好。谁能帮忙?
不是没有你告诉我们什么不工作/你得到了什么错误。 _“一堆错误”_并不是很丰富。 – Epodax
如果这是你的代码的精确副本,你应该至少删除最后3行(一个是空的,但仍然删除它) – RST
对不起,这里是WP中的错误的屏幕截图。 https://www.dropbox.com/s/w6w1lphv7bvbwt8/Screen%20Shot%202016-10-04%20at%208.58.56%20AM.png?dl=0 – Riddle