0
我想要parts/lesson-links.php
不包括在get_the_lesson_contenttype()
等于“提示”或“主要课程”。为什么这个PHP if语句仍然包含里面的内容?
所以我这样做:
<h2><?php echo get_the_lesson_contenttype(); ?></h2>
<?php if (get_the_lesson_contenttype() != 'Hints' || get_the_lesson_contenttype() != 'Main Lesson') { ?>
<?php
include(locate_template('parts/lesson-links.php'));
?>
<?php } ?>
但你可以在这个页面中看到:http://clo2015.chineselearnonline.com/lessoncontent/lesson-004-hints-and-tips/
parts/lesson-links.php
仍在增加。我做错了什么?
编辑:
奇怪的是它的工作原理没有||
,只增加Hint
:
<?php if (get_the_lesson_contenttype() != 'Hints') include(locate_template('parts/lesson-links.php'));?>
这将永远是事实。 'get_the_lesson_contenttype'不能是两个值。了解'AND'和'OR'之间的区别。 – PeeHaa 2015-04-06 02:53:58
@PeeHaa所以我应该写什么呢? – alexchenco 2015-04-06 02:56:03
我想你想'if(get_the_lesson_contenttype()!='Hints'&& get_the_lesson_contenttype()!='Main Lesson'){?>'。这样一来,只有当它不是“提示”而且它不是“主要课程”时才会包含它。 – chris85 2015-04-06 02:57:13