您好我正在尝试为两个页面和帖子使用两个不同的侧边栏。
为此,我使用以下条件来测试它是否是一个页面(如果是,请致电"sidebar-15"
,否则请致电"blog"
)。
<?php
if (is_page()){
dynamic_sidebar( 'sidebar-15' );
}
else {
get_sidebar( 'blog' );
}
?>
但是,在页面上它仍在调用blog side bar
。有什么我做错了吗?
答案 0 :(得分:0)
<?php get_sidebar( $name_of_sidebar_file ); ?>
例如: 文件:sidebar-right.php和sidebar-left.php 主叫:
get_sidebar('right');
get_sidebar('left');