开发者 | ShinichiN |
---|---|
更新时间 | 2016年9月9日 23:03 |
PHP版本: | 4.4 及以上 |
WordPress版本: | 4.6.1 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
is_active_sidebar()
when calling dynamic_sidebar()
function.
This will work.
if ( is_active_sidebar( 'sidebar-1' ) ) { dynamic_sidebar( 'sidebar-1' ); }
This doesn't work.
dynamic_sidebar( 'sidebar-1' );
If you only want to output your custom sidebar, put this code on where you want to display the sidebar in your theme.
do_action( 'dynamically_dynamic_sidebar' );
This Plugin published on GitHub.
ウィジェットエリアをいくつでも定義し、カテゴリやタグ、カスタム分類ごとに差し替えたり、投稿・ページ・カスタム投稿から使いたいサイドバーを指定したりすることができます。「スクリーンショット」のタブをごらんいただくと、イメージが湧きやすいと思います。
dynamically-dynamic-sidebar
to the /wp-content/plugins/
directory/wp-admin/themes.php?page=dynamically-dynamic-sidebar
, which is located under Appearance
Unlimited.
Choose the target widget area in admin panel. The admin page for this plugin is located at Admin > Appearance > Dynamically Dynamic Sidebar.
You need to make sure that the call of dynamic_sidebar is properly wrapped with is_active_sidebar() conditional tag.
if ( is_active_sidebar( 'sidebar-1' ) ) { dynamic_sidebar( 'sidebar-1' ); }
Or you can just output your dynamically created sidebar with do_action( 'dynamically_dynamic_sidebar' );
, too.