All in One SEO Packでカテゴリやカスタム投稿タイプのアーカイブタイトル・descriptionを設定する方法
最終更新日:
WordPressでAll in One SEO Packを使用時に、カテゴリやカスタム投稿タイプのアーカイブのtitle・descriptionを設定する方法をメモ
titleの設定方法
functions.php内に
function aioseop_title_fix($title){ if(is_post_type_archive('sample')){ $title = 'カスタム投稿タイプsampleのタイトル'; } elseif (is_category('cat')) { $title = 'catカテゴリのタイトル'; } return $title; } add_filter('aioseop_title', 'aioseop_title_fix');
でOK
descriptionの設定方法
functions.php内に
function custom_aioseop_description($description){ if (is_post_type_archive('sample')) { $description = 'カスタム投稿タイプsampleのディスクリプション'; } elseif (is_category('cat')) { $description = 'catカテゴリのディスクリプション'; } elseif (is_category()) { $description = get_queried_object()->name .'カテゴリのディスクリプション'; } elseif (in_category('cat') && is_single()) { $description = get_the_title() .'catカテゴリの投稿のディスクリプション'; } return $description; } add_filter('aioseop_description', 'custom_aioseop_description');
でOK
最新バージョンのプラグインは
aioseop_description → aioseo_description
aioseop_title → aioseo_title
に変更することで対応できます。
WordPressのおすすめ参考書
bookfan 1号店 楽天市場店
¥3,300 (2025/02/12 22:17時点 | 楽天市場調べ)