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