KH-WEBLOG TOP > WEBメモ > WordPress > All in One SEO Packでカテゴリやカスタム投稿タイプのアーカイブタイトル・descriptionを設定する方法

All in One SEO Packでカテゴリやカスタム投稿タイプのアーカイブタイトル・descriptionを設定する方法

最終更新日:

WordPressでAll in One SEO Packを使用時に、カテゴリやカスタム投稿タイプのアーカイブのtitle・descriptionを設定する方法をメモ

コーディング・WordPress化作業を代行します

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化作業を代行します

WordPressのおすすめ参考書

\楽天ポイント5倍セール!/
楽天市場
\ポイント5%還元!/
Yahooショッピング
楽天Kobo電子書籍ストア
¥3,278 (2024/04/19 19:05時点 | 楽天市場調べ)
\楽天ポイント5倍セール!/
楽天市場
\ポイント5%還元!/
Yahooショッピング

TAGS

.htaccess ActionScript All in one seo pack Contact Form 7 CSS CSS3 EC-CUBE Flash HTML HTML5 JavaScript jQuery LightBox PHP RSS SEO WordPress アイキャッチ画像 アクセス解析 カスタムフィールド カテゴリー カラーミーショップ カート コメント ショートコード テンプレートタグ ドロップダウンメニュー パーマリンク フォーム フルスクリーン ブログカード プラグイン ページテンプレート ページナビ ページ分割 マウスイベント リダイレクト リンク リンクカード レンタルサーバー ロールオーバー 携帯サイト 条件分岐 正規表現 関連記事