Wordpress > ページごとに違うサイドバー

functions.php

<?php
register_sidebar();
register_sidebar(array(‘name’=> ‘home’));
?>
 

これで、管理画面の「外観>ウィジェット」を開くと、「サイドバー1」と「home」が表示されている。


サイドバーテンプレート

サイドバーテンプレート「sidebar.php」をコピーして「sidebar-home.php」を作る。
sidebar.php
<?php if(function_exists('dynamic_sidebar')) dynamic_sidebar(); ?>
 

sidebar-home.php
<?php if(function_exists('dynamic_sidebar')) dynamic_sidebar('home'); ?>
 


ページテンプレートにサイドバーを組み込む

page-home.php
<?php get_sidebar('home'); ?>」
 
page.php
<?php get_sidebar(); ?>」
 







最終更新:2013年02月06日 22:22