我在我的header.php
尝试让layerslider根据页面id显示。
它适用于滑块1和2。但在滑块2之后,每页都会得到滑块2。滑块3和4未显示。为什么?
<?php
if(is_front_page()){layerslider(1);}
else
if(is_page(\'32\'or\'36\'or\'38\'or\'40\')){layerslider(2);}
else
if(is_page(\'46\'or\'48\'or\'52\'or\'58\'or\'60\'or\'62\'or\'64\'or\'66\'or\'69\'or\'71\')){layerslider(3);}
else
if(is_page(\'161\'or\'163\'or\'169\'or\'173\'or\'176\'or\'179\'or\'182\'or\'185\'or\'188\'or\'191\'or\'196\'or\'199\'or\'202\')){layerslider(3);}
else
if(is_page(\'219\'or\'221\'or\'230\'or\'232\'or\'234\'or\'236\'or\'239\'or\'244\'or\'247\'or\'251\'or\'264\')){layerslider(4);}
else
if(is_page(\'277\')){layerslider(5);}
?
SO网友:Matthieu
如果希望is\\U页接受多个参数,则需要一个数组。看见http://codex.wordpress.org/Function_Reference/is_page#Examples
<?php
if(is_front_page()){layerslider(1);}
else
if(is_page(array(3,36,38,40))){layerslider(2);}
else
if(is_page(array(46,48,52,58,60,62,64,66,69,71))){layerslider(3);}
else
(…)
?>
应该有用。您不需要引用页面id