如何在条件中添加条件

时间:2021-08-20 08:52:46

I have this code

我有这个代码

<?php if (is_page_template()) {
} else {
get_sidebar();
}
?>

I want to integrate two options to the if condition

我想将两个选项集成到if条件中

if (is_front_page())

how do i put it together in the php code so it would work

我如何将它放在PHP代码中,以便它可以工作

i tried

<?php if (is_page_template()) ||  (is_front_page()){
} else {
get_sidebar();
}
?>

but it does not work. sorry I'm not really good at programming.

但它不起作用。抱歉,我不擅长编程。

any help would be appreciate it :)

任何帮助将是欣赏它:)

3 个解决方案

#1


0  

You just had two extra parenthesis.

你只有两个额外的括号。

The Good

<?php 
if (is_page_template() ||  is_front_page())
{
} else {
    get_sidebar();
}
?>

The Mistake

<?php if (is_page_template()) ||  (is_front_page()){
                            ^-----^  Not Required

#2


0  

There is issue with the closing bracket ')' of if condition. Try this.

if条件的结束括号')'存在问题。试试这个。

<?php if (is_page_template() ||  is_front_page()){
} else {
get_sidebar();
}
?>

#3


0  

You close the conditional too early

你太早关闭条件

<?php if (is_page_template()) ||  (is_front_page()){

this will work:

这将工作:

<?php if (is_page_template() ||  is_front_page()){

#1


0  

You just had two extra parenthesis.

你只有两个额外的括号。

The Good

<?php 
if (is_page_template() ||  is_front_page())
{
} else {
    get_sidebar();
}
?>

The Mistake

<?php if (is_page_template()) ||  (is_front_page()){
                            ^-----^  Not Required

#2


0  

There is issue with the closing bracket ')' of if condition. Try this.

if条件的结束括号')'存在问题。试试这个。

<?php if (is_page_template() ||  is_front_page()){
} else {
get_sidebar();
}
?>

#3


0  

You close the conditional too early

你太早关闭条件

<?php if (is_page_template()) ||  (is_front_page()){

this will work:

这将工作:

<?php if (is_page_template() ||  is_front_page()){