简体   繁体   English

这个php if语句有什么问题吗?

[英]Is there something wrong with this php if statement?

Here is what I have included in the head of my WordPress site. 这是我在WordPress网站的head所包含的内容。 However, it is producing a blank page. 但是,它正在生成一个空白页面。 Is there something I might have overlooked? 有什么我可能会忽略的吗?

<?php if (is_page('talent')) || (is_page('work')) { ?>
<script src="<?php bloginfo('template_url'); ?>/js/jquery.fancybox-1.3.4.pack.js"></script>
<?php } ?>

The answers of both @chaitanyaMutyala and @Poonam are both right, but neither is complete. @chaitanyaMutyala和@Poonam的答案都是正确的,但两者都不完整。 You need both fixes. 你需要两个修复程序。 The parenthesis don't match in your if statement and you need to echo the url: 括号在if语句中不匹配,您需要echo显url:

<?php if (is_page('talent') || (is_page('work')) { ?>
    <script src="<?php echo bloginfo('template_url'); ?>/js/jquery.fancybox-1.3.4.pack.js"></script>
<?php } ?>
echo bloginfo('template_url'); 

Breakets are mismatching 隔断是不匹配的

if (is_page('talent') || (is_page('work'))){

try replacing your if statement with the given 尝试用给定的替换你的if语句

and echo is missing before bloginfo('template_url') bloginfo('template_url')之前缺少和echo

You can chek below code. 你可以在下面代码。

->if statement replace with this one: - > if语句替换为此语句:

if (is_page('talent') || (is_page('work')) {

-> src attribute in script tag replace with below one: - >脚本标记中的src属性替换为下面的一个:

echo get_bloginfo('template_url'); ?>/js/jquery.fancybox-1.3.4.pack.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM