在wordpress中调用侧边栏

时间:2014-03-21 06:01:29

标签: php wordpress

您好我正在尝试为两个页面和帖子使用两个不同的侧边栏。

为此,我使用以下条件来测试它是否是一个页面(如果是,请致电"sidebar-15",否则请致电"blog")。

<?php 
     if (is_page()){
      dynamic_sidebar( 'sidebar-15' );
     }
     else {
      get_sidebar( 'blog' );
     }
?> 

但是,在页面上它仍在调用blog side bar。有什么我做错了吗?

1 个答案:

答案 0 :(得分:0)

get_sidebar function

<?php get_sidebar( $name_of_sidebar_file ); ?>

例如: 文件:sidebar-right.php和sidebar-left.php 主叫:

get_sidebar('right');
get_sidebar('left');