ワードプレスについて。


各ページのタイトルを「ページ名:サイト名」としたいと考えており、
下記の様にしたのですが、

<title>
<?php wp_title(':', true, 'right'); ?>
<?php bloginfo('name'); ?>
</title>

結果は、この様になってしまいます。

「サイト名:ページ名:サイト名」


解決方法を教えて下さい。

バージョンは4.0.1です。

RCG forest というテーマを元にカスタマイズを試みています。

宜しくお願いします。

回答の条件
  • 1人1回まで
  • 登録:
  • 終了:2015/05/02 14:36:49
※ 有料アンケート・ポイント付き質問機能は2023年2月28日に終了しました。

ベストアンサー

id:a-kuma3 No.1

回答回数4974ベストアンサー獲得回数2154

ポイント100pt

RCG forest のテーマでは、wp_title で「サイト名 セパレータ ページ名」となるように実装されています。
http://themes.svn.wordpress.org/rcg-forest/2.0.2/functions.php

// Title
function rcg_forest_wp_title($title, $sep) {
    global $paged, $page;
    $title = get_bloginfo('name') . " $sep " . $title;      // ★ここ!
    if($paged >= 2 || $page >= 2) {
        $title .= sprintf(__('Page %s', 'rcg-forest'), max($paged, $page));
    }
    else {
        $title = preg_replace('#\\s\\|\\s$#', '', $title);
    }
    return $title;
}
add_filter('wp_title', 'rcg_forest_wp_title', 10, 2);

ページ番号をタイトルに含めることも含めて RCG forest の機能を無効にするなら、add_filter をコメントアウトすれば良いと思います。

// Title
function rcg_forest_wp_title($title, $sep) {
    global $paged, $page;
    $title = get_bloginfo('name') . " $sep " . $title;
    if($paged >= 2 || $page >= 2) {
        $title .= sprintf(__('Page %s', 'rcg-forest'), max($paged, $page));
    }
    else {
        $title = preg_replace('#\\s\\|\\s$#', '', $title);
    }
    return $title;
}
// ★ここをコメントアウト
// add_filter('wp_title', 'rcg_forest_wp_title', 10, 2);

ページ番号を含める機能を活かすのであれば、サイト名をつけているところをこめんとあうとしてください。

// Title
function rcg_forest_wp_title($title, $sep) {
    global $paged, $page;
// ★ここをコメントアウト
//  $title = get_bloginfo('name') . " $sep " . $title;
    if($paged >= 2 || $page >= 2) {
        $title .= sprintf(__('Page %s', 'rcg-forest'), max($paged, $page));
    }
    else {
        $title = preg_replace('#\\s\\|\\s$#', '', $title);
    }
    return $title;
}
add_filter('wp_title', 'rcg_forest_wp_title', 10, 2);

コメントはまだありません

この質問への反応(ブックマークコメント)

「あの人に答えてほしい」「この質問はあの人が答えられそう」というときに、回答リクエストを送ってみてましょう。

これ以上回答リクエストを送信することはできません。制限について

回答リクエストを送信したユーザーはいません