wordpressで 表示するカテゴリー毎に違うサイドバーを出そうと、sidebar.phpとsidebar2.phpとsidbar3.phpと言うのを作って、
<?php if (in_category(1)): ?> <?php get_sidebar2(); ?> <?php elseif (in_category(23)): ?> <?php get_sidebar3(); ?> <?php else: ?> <?php get_sidebar(); ?> <?php endif; ?>の様にしたらエラーが出ました。
で、調べると、sidebar.phpと言うのはwordpressで決められた名前のようで、サイドバーの名前はsidebar.phpとsidebar-2.phpとsidbar-3.phpの様に枝番にして、表示するソースは、
<?php if (in_category(1)): ?>
<?php get_sidebar('2'); ?>
<?php elseif (in_category(23)): ?>
<?php get_sidebar('3'); ?>
<?php else: ?>
<?php get_sidebar(); ?>
<?php endif; ?>
の様にしなければならなかった。
これで解決!



コメントする