2026年7月29日
2026年7月29日
WordPressのBest Of(ベスト)コンテンツのSEO
はじめに
「Best of」コンテンツは、ユーザーがサイトを初めて訪れる際にも魅力的なエクスペリエンスを提供する一方で、SEOの観点から重要な役割を果たします。この記事では、「Best of」コンテンツを作成し最適化するための具体的な手順と設定方法について解説します。
症状・背景
- 「Best of」コンテンツがないため、サイト訪問者への訴求力が不足している
- 同じ種類の「Best of」コンテンツが複数存在し、ユーザーエクスペリエンスに支障をきたしている
- サイト内の重要なページへのトラフィックが「Best of」コンテンツ経由で流入していない
- 「Best of」コンテンツがSEO対策されていないため、検索エンジンからの評価が低くなっている
手順・設定方法
ステップ1: WordPressテーマとプラグインの最適化
# 「Best of」コンテンツ用にカスタムテンプレートを追加する場合
cd /path/to/wordpress-theme
mkdir best-of-template
touch single-bestof.php
# テンプレートファイルに以下のPHPコードを追記
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post();
// The best of post content goes here
the_content();
endwhile; ?>
</main>
</div>
<?php get_footer(); ?>
# テンプレートを有効にするプラグインの設定
cd /path/to/wordpress-plugins
wp plugin activate custom-template-activate
ステップ2: カスタムフィールドとメタデータの設定
# 「Best of」コンテンツ用にカスタムフィールドを追加する
add_post_meta($post_id, 'best_of', 'true');
# メタデータを使用して「Best of」コンテンツをマークアップ
function custom_bestof_markup() {
global $post;
if(get_post_meta($post->ID, 'best_of', true) == 'true') { ?>
<div class="custom-bestof-markup">
<!-- Best of コンテンツのマークアップ -->
</div>
<?php }
}
add_action('the_content', 'custom_bestof_markup');
ステップ3: カスタム投稿タイプとタクソノミーの設定
# WordPressのカスタム投稿タイプを定義
function create_custom_post_type() {
$args = array(
'label' => __('Best of'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'bestof')
);
register_post_type( 'bestof', $args );
}
add_action( 'init', 'create_custom_post_type' );
# カスタムタクソノミーを作成
function create_custom_taxonomy() {
$labels = array(
'name' => _x( 'Category', 'taxonomy general name' ),
'singular_name' => _x( 'Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Categories' ),
// 他のラベル定義
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'bestof-category' ),
);
register_taxonomy( 'bestof_category', 'bestof', $args );
}
add_action( 'init', 'create_custom_taxonomy' );
ステップ4: カスタムフィールドの追加と設定
# 「Best of」コンテンツ用にカスタムフィールドを追加
function add_bestof_meta_boxes() {
add_meta_box(
'bestof-meta-box',
__( 'Best of Meta Box', 'textdomain' ),
'render_bestof_meta_box',
'post',
'normal',
'high'
);
}
add_action( 'add_meta_boxes', 'add_bestof_meta_boxes' );
# カスタムフィールドの表示と保存
function render_bestof_meta_box() {
global $post;
$value = get_post_meta( $post->ID, '_bestof_value', true );
// メタボックスフォームのHTMLを追加
}
注意事項
- カスタムフィールドやメタデータは適切に命名し、一貫性を持たせることが重要です。
- 「Best of」コンテンツ用のカスタム投稿タイプとタクソノミーを作成する際には、既存の投稿タイプやタクソノミーとの干渉を避けるように注意してください。
- パフォーマンスに影響を与えないよう、大量の「Best of」コンテンツがある場合は適切なキャッシュ設定を行うことを推奨します。
まとめ
1. カスタムテンプレート: 「Best of」コンテンツ用にカスタムテンプレートを準備し、WordPressテーマ内で有効化します。
2. メタデータの利用: カスタムフィールドとメタデータを使用して「Best of」コンテンツをマークアップし、SEO対策を行います。
3. カスタム投稿タイプ: WordPressのカスタム投稿タイプを作成し、必要に応じてカスタムタクソノミーも追加します。
4. パフォーマンス最適化: キャッシュプラグインやCDNサービスを活用して「Best of」コンテンツのパフォーマンスを向上させます。
関連記事: