如果当前页面没有使用特定的页面模板,我一直使用这个if条件语句来显示内容;
if (! is_page_template('template-custom.php')) {
<!-- show some content -->
}一直运作得很好。只有现在,如果当前页面没有使用2个模板中的一个,则需要修改语句以显示内容(因此,如果当前页面使用template-custom.php或template-custom2.php,则不要显示内容)。
我试过这个;
if (! is_page_template('template-custom.php') || is_page_template('template-custom2.php')) {
<!-- show some content -->
}还有这个;
if (! is_page_template('template-custom.php') || ! is_page_template('template-custom2.php')) {
<!-- show some content -->
}但对阿维尔来说。
有什么建议吗?
发布于 2013-09-23 10:19:46
如果不想显示内容,如果当前模板是template-custom.php或template-custom2.php,则可以使用:
if (!is_page_template('template-custom.php') && !is_page_template('template-custom2.php')) {
<!-- show some content when you AREN NOT in template-custom.php NOR template-custom2.php -->
}或
if (is_page_template('template-custom.php') || is_page_template('template-custom2.php')) {
<!-- show some content when you ARE in template-custom.php OR template-custom2.php -->
}发布于 2013-09-23 10:20:46
根据德摩根定律
"not (A or B)" is the same as "(not A) and (not B)"发布于 2013-09-23 10:13:44
试试这个:
if (! is_page_template('template-custom.php') || ! is_page_template('template-custom2.php')) {
<!-- show some content -->
}https://wordpress.stackexchange.com/questions/115281
复制相似问题