是否可以分配
get_theme_mod('dds') !== 'false';
到变量并将其包含在if语句中而不是输入整个内容?
这是我正在处理的if语句:
$DDS = get_theme_mod('dds') !== 'false';
if( is_category() && $DDS ) :
//output some css style
endif;
我收到错误:解析错误:语法错误,意外':'
答案 0 :(得分:1)
如果声明括号,请参阅下面的代码以删除错误,因为您不完整而收到错误。
$DDS = get_theme_mod('dds') !== 'false';
if( is_category() && $DDS ) :
//output some css style
endif;
另一种解决方案:无需变量即可直接添加代码如果条件您获得与上述代码相同的解决方案
if( is_category() && ( get_theme_mod('dds') !== 'false' ) ) :
//output some css style
endif;
答案 1 :(得分:0)
为什么你需要!= false
,似乎多余?