Title: サイドバーウィジェット h2タグ から div に変更したい。
Last modified: 2016年7月30日

---

# サイドバーウィジェット h2タグ から div に変更したい。

 *  解決済 [sato_ru](https://ja.wordpress.org/support/users/sato_ru/)
 * (@sato_ru)
 * [13年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%82%a6%e3%82%a3%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88-h2%e3%82%bf%e3%82%b0-%e3%81%8b%e3%82%89-div-%e3%81%ab%e5%a4%89%e6%9b%b4%e3%81%97%e3%81%9f%e3%81%84/)
 * WordPress 初心者です。
 * サイドバーウィジェットが、 h2タグなってしまい、SEO内部対策上不要なため、divに
   変更したいのですが、フォーラムを見たりググったりしましたがやり方がわかりません。
 * どなたかご教示お願い致します。

5件の返信を表示中 - 1 - 5件目 (全5件中)

 *  [mogue](https://ja.wordpress.org/support/users/mogue/)
 * (@mogue)
 * [13年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%82%a6%e3%82%a3%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88-h2%e3%82%bf%e3%82%b0-%e3%81%8b%e3%82%89-div-%e3%81%ab%e5%a4%89%e6%9b%b4%e3%81%97%e3%81%9f%e3%81%84/#post-155196)
 * まったくの勘なのでヒントとして捕らえてください。
 * [register_sidebar](http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/register_sidebar)
   でどうにかできませんか。
 * あるいはお使いのテーマにあるfunction.php内で書き換えができないでしょうか。
    これ
   はデフォルトの「twentytenテーマ」にある関数の一部です。 この例ではh3に書き換え
   られています。デフォルトはh2になっているのが上で示したリンク先を見るとわかります。
 *     ```
       function twentyten_widgets_init() {
       	// Area 1, located at the top of the sidebar.
       	register_sidebar( array(
       		'name' => __( 'Primary Widget Area', 'twentyten' ),
       		'id' => 'primary-widget-area',
       		'description' => __( 'The primary widget area', 'twentyten' ),
       		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
       		'after_widget' => '</li>',
       		'before_title' => '<h3 class="widget-title">',
       		'after_title' => '</h3>',
       	) );......
       ```
   
 * めんどくさければコア（/wp-includes/widgets.php）にある、477行目の
 *     ```
       function register_sidebars($number = 1, $args = array()) {
       	global $wp_registered_sidebars;
       	$number = (int) $number;
   
       	if ( is_string($args) )
       		parse_str($args, $args);
   
       	for ( $i = 1; $i <= $number; $i++ ) {
       		$_args = $args;
   
       		if ( $number > 1 )
       			$_args['name'] = isset($args['name']) ? sprintf($args['name'], $i) : sprintf(__('Sidebar %d'), $i);
       		else
       			$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
   
       		// Custom specified ID's are suffixed if they exist already.
       		// Automatically generated sidebar names need to be suffixed regardless starting at -0
       		if ( isset($args['id']) ) {
       			$_args['id'] = $args['id'];
       			$n = 2; // Start at -2 for conflicting custom ID's
       			while ( isset($wp_registered_sidebars[$_args['id']]) )
       				$_args['id'] = $args['id'] . '-' . $n++;
       		} else {
       			$n = count($wp_registered_sidebars);
       			do {
       				$_args['id'] = 'sidebar-' . ++$n;
       			} while ( isset($wp_registered_sidebars[$_args['id']]) );
       		}
       		register_sidebar($_args);
       	}
       }
       ```
   
 * をdivに書き換えてしまうというのも手かもしれませんが、functionで書き換えられる
   ようになっているので、それを使うのが第一でしょう。
    この関数をfunction.phpに貼
   ってしまって、divに書き換える、っていうのでもいけた気がしますが、荒ワザでしょう
   か。他の皆さんはどう思われますか？
 *  モデレーター [けい (Kei Nomura)](https://ja.wordpress.org/support/users/mypacecreator/)
 * (@mypacecreator)
 * [13年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%82%a6%e3%82%a3%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88-h2%e3%82%bf%e3%82%b0-%e3%81%8b%e3%82%89-div-%e3%81%ab%e5%a4%89%e6%9b%b4%e3%81%97%e3%81%9f%e3%81%84/#post-155198)
 * > 他の皆さんはどう思われますか？
 * とのことなので援護射撃を。
    mogueさんのおっしゃるとおり、お使いのテーマのfunctions.
   phpで変更するのがよいと思います。
 * sato_ruさんがTwentyTenをお使いなら上述の通りでOKでしょうし、
    他のテーマをお使い
   の場合でも該当する部分を書き換えればいいはずです。 （自作テーマや、functions.
   phpがないテーマということもあり得ますのでケースバイケースですが）
 * >sato_ruさん
    と、いうことでまずはお使いのテーマが何なのか開示してください。
 *  トピック投稿者 [sato_ru](https://ja.wordpress.org/support/users/sato_ru/)
 * (@sato_ru)
 * [13年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%82%a6%e3%82%a3%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88-h2%e3%82%bf%e3%82%b0-%e3%81%8b%e3%82%89-div-%e3%81%ab%e5%a4%89%e6%9b%b4%e3%81%97%e3%81%9f%e3%81%84/#post-155199)
 * mogueさん、mypacecreatorさん、どうもありがとうございます。
 * テーマは、「[ホームページビルダー17](http://www.justsystems.com/jp/products/hpb/price.html)」
   ＊「
   JustSystems Homepage Builder Version 17.0.3.0 for Windows」によって作成されま
   した。とテーマの管理のところに記載されています。
 * function.php　の　register_sidebar　を下に表記しましたが、該当すH2タグが書かれ
   ていません。
 * また、コア（/wp-includes/widgets.php）とのことですが、
    /wp-includes/ の配下に
   widgets.php が存在しません。「widgets」と名の付くものは default-widgets.php のみ
   となります。
 * よろしくお願い申し上げます。
 *     ```
       register_sidebar();
   
       add_theme_support( 'post-thumbnails' );
       set_post_thumbnail_size( 550, 400, true );
   
       register_post_type(
       	'news',
       	array(
       	'label'         => 'ニュース',
       	'hierarchical'  => false,
       	'public'        => true,
       	'has_archive'   => true,
       	'supports'      => array(
       	'title',
       	'editor',
       	'thumbnail',
       	'comments'
       	),
       	'menu_position' => 5,
       	'menu_icon'     => get_bloginfo('template_url') . '/post-types/menu_news.png'
       	)
       );
   
       register_taxonomy(
       	'newscat',
       	'news',
       	array(
       	'label'        => 'ニュースのカテゴリー',
       	'hierarchical' => true,
       	)
       );
   
       function manage_news_columns( $columns ) {
       	$columns['fcategory'] = "カテゴリー";
       	return $columns;
       }
   
       function add_news_column( $column_name, $post_id ){
       	if ( 'fcategory' == $column_name ) {
       		$fcategory = get_the_term_list( $post_id, 'newscat' );
       		if ( $fcategory ) {
       			echo $fcategory;
       		} else {
       			echo __('None');
       		}
       	}
       }
   
       add_filter( 'manage_edit-news_columns', 'manage_news_columns' );
       add_action( 'manage_news_posts_custom_column',	'add_news_column', 10, 2 );
   
       add_action('admin_head', 'plugin_header_news');
       function plugin_header_news() {
       	global $post_type;
       ?>
       <style>
       	<?php if (($_GET['post_type'] == 'news') || ($post_type == 'news')) : ?>
       		#icon-edit { background: url('<?php echo get_bloginfo('template_url') . '/post-types/icon_news.png';?>') no-repeat transparent; background-size:auto !important; }
       	<?php endif; ?>
       </style>
       <?php
       }
   
       if ( ! isset( $content_width ) )
       	$content_width = 648;
       ```
   
 *  モデレーター [けい (Kei Nomura)](https://ja.wordpress.org/support/users/mypacecreator/)
 * (@mypacecreator)
 * [13年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%82%a6%e3%82%a3%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88-h2%e3%82%bf%e3%82%b0-%e3%81%8b%e3%82%89-div-%e3%81%ab%e5%a4%89%e6%9b%b4%e3%81%97%e3%81%9f%e3%81%84/#post-155200)
 * それだったら、挙げてもらったコードの1行目
 * `register_sidebar();`
 * が該当しますね。2行目以降は関係ないです。
 * 詳しくは、
    [関数リファレンス/register sidebar – WordPress Codex 日本語版](http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/register_sidebar)
   を参照していただくとわかりますが、 `register_sidebar();`の()内に、必要な設定を
   追記すればOKです。 ※括弧内が空、ということはすべてWordPress側が定めた初期設定
   値を適用している、という意味です。
 * Codexを読むとregister_sidebarのパラメータ一覧は
 * >  name – サイドバー名
   >  id – サイドバー id description – サイドバーの説明 (2.9
   > 以降) before_widget – ウィジェットの前のテキスト after_widget – ウィジェット
   > の後のテキスト before_title – タイトルの前のテキスト after_title – タイトル
   > の後のテキスト
 * となっています。
 * 今回は、ウィジェットのタイトルにあたる見出し部分のマークアップ変更なので、
    before_title–
   タイトルの前のテキスト after_title – タイトルの後のテキスト だけを変更すればOK
   です。
 *     ```
       register_sidebar( array(
       	'before_title' => '<div>',
       	'after_title' => '</div>'
       ) );
       ```
   
 * こんな感じですね。
    変な全角スペースやコンマ、括弧の閉じミス等にご注意を。
 *  トピック投稿者 [sato_ru](https://ja.wordpress.org/support/users/sato_ru/)
 * (@sato_ru)
 * [13年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%82%a6%e3%82%a3%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88-h2%e3%82%bf%e3%82%b0-%e3%81%8b%e3%82%89-div-%e3%81%ab%e5%a4%89%e6%9b%b4%e3%81%97%e3%81%9f%e3%81%84/#post-155238)
 * mypacecreatorさん、どうもありがとうございました！
 * OKでした。うまくいきました！
 * 本当にありがとうございました。
 * 本件は、SEO内部対策を中心したSEO対策会社のエンジニアから、アルゴリズム解析から
   H3タグは1ページに４つ以下が最適という指示を頂戴したためでした。

5件の返信を表示中 - 1 - 5件目 (全5件中)

 トピック「サイドバーウィジェット h2タグ から div に変更したい。」には新たに返信
することはできません。

## タグ

 * [サイドバーウィジェット](https://ja.wordpress.org/support/topic-tag/%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%82%a6%e3%82%a3%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88/)
 * [ホームページビルダー](https://ja.wordpress.org/support/topic-tag/%e3%83%9b%e3%83%bc%e3%83%a0%e3%83%9a%e3%83%bc%e3%82%b8%e3%83%93%e3%83%ab%e3%83%80%e3%83%bc/)
 * [div](https://ja.wordpress.org/support/topic-tag/div/)
 * [h2](https://ja.wordpress.org/support/topic-tag/h2/)
 * [h3](https://ja.wordpress.org/support/topic-tag/h3/)

 * フォーラム: [使い方全般](https://ja.wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5件の返信
 * 3人の参加者
 * 最後の返信者: [sato_ru](https://ja.wordpress.org/support/users/sato_ru/)
 * 最後の活動: [13年、 11ヶ月前](https://ja.wordpress.org/support/topic/%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%82%a6%e3%82%a3%e3%82%b8%e3%82%a7%e3%83%83%e3%83%88-h2%e3%82%bf%e3%82%b0-%e3%81%8b%e3%82%89-div-%e3%81%ab%e5%a4%89%e6%9b%b4%e3%81%97%e3%81%9f%e3%81%84/#post-155238)
 * 状態: 解決済

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
