它将wrapper8应用于任何新页面,因为它不是第一条if/else语句中的首页。您需要将它们全部连接到一个if/else语句字符串中。
这里的代码稍微整理了一下(如果不是那么晚,我会尽量把它简化为一个数组):
<?php
$pages = array(\'About Us\',\'Our Work\', \'Get Involved\', \'About Namibia\', \'Donate\', \'Photos\', \'Sitemap\');
$wrappers = array(
\'About Us\' => \'wrapper2\',
\'Our Work\' => \'wrapper3\',
\'Get Involved\' => \'wrapper4\',
\'About Namibia\' => \'wrapper5\',
\'Donate\' => \'wrapper6\',
\'Photos\' => \'wrapper7\',
\'Sitemap\' => \'wrapper9\'
);
if ( is_front_page() ) {
$wrap = \'wrapper\';
} elseif (is_page($pages)) {
$wrap = $wrappers[get_the_title()];
} else {
$wrap = \'wrapper8\';
}
?>
<div class="<?php echo $wrap; ?>">