functions.phpを使い3カラムのサイドバーウィジェット(widget)をh2からh3に変更

functions3カラムwidget

運営中の 3カラム WordPress サイトで、ウィジェット(widget)の h2 を h3 に変更してるのですが、wp-includes の widgets.php を編集する方法で対応していたので、これを functions.php でやるようにカスタマイズしました。



functions.php でh2 を h3 に変更

サイドバーは sidebar.php と sidebar2.php の2つ用意。

sidebar.php の記述

<div id="sidebar">
<ul>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>

    <?php endif; ?>
</ul>
</div>

sidebar2.php の記述

<div id="sidebar2">
 <ul>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>
   <?php endif; ?>
 </ul>
</div>

functions.php の記述

<?php
if (function_exists('register_sidebar')){
	register_sidebar(array(
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3>',
		'after_title' => '</h3>',
		'name'=>'Sidebar'
	));
	register_sidebar(array(
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3>',
		'after_title' => '</h3>',
		'name'=>'Sidebar2'
	));
}
?>

以上で OK 。

「ul」 内の 「div」 は Valid で引っかかる。

また何かで使うこともあるので備忘録として残しておきます。


コメント/トラックバック
トラックバック用URL:

この記事のコメント・トラックバックRSS

この記事へのコメント・トラックバックはありません。

コメントをどうぞ

:wink: :twisted: :titi: :roll: :oops: :omiso: :mrgreen: :lol: :idea: :evil: :cry: :ase: :arrow: :?: :-| :-x :-o :-P :-D :-? :) :( :!: 8-O 8)