フッター上ウィジェットの追加
///////////////////////////////////////
// フッター上ウィジェットの追加
///////////////////////////////////////
register_sidebars(1,
array(
'name'=>'フッター上',
'id' => 'widget-top-footer',
'description' => 'フッター上に表示されるウイジェット。',
'before_widget' => '<div id="%1$s" class="widget-top-footer %2$s">',
'after_widget' => '</div>',
'before_title' => '<div class="widget-top-footer-title">',
'after_title' => '</div>',
));
///////////////////////////////////////
// フッター上にウィジェットを追加する処理
///////////////////////////////////////
add_action( 'get_footer', function () {
if ( is_active_sidebar( 'widget-top-footer' ) //ウィジェットが設定されているとき
) {
//広告(AdSense)タグを記入
ob_start();//バッファリング
dynamic_sidebar( 'widget-top-footer' );//フッター上ウィジェットの表示
echo ob_get_clean();
}
});
/* フッター上ウィジェットのスタイル */
.widget-top-footer {
text-align: center;
}