WordPress SEO Yoast ヘッダーのコメントを削除

Yoastは素晴らしい

いいね!
英語何言ってるかよくわからないけど。

All in One SEO Packもよかったけど、Yoastの方が評価が高かったもんで乗り換えた。
全然使いこなせてないけど。

みんながいいね!って言っているものは、おそらくいいものなんだろうてきな感じで導入。

WordPress SEO by Yoastの設定

細かい。
色々いじってたら、サイトがくっそ重くなった。

でも、やっぱりYoastはいいね。
当分これだね、無料のSEOで十分だよ。

Yoastを作ってくれた作成者: Joost de Valkさんには感謝でいっぱいです。

こんな素敵なプラグインを作ってくれてありがとう。

うん、素晴らしい。

Clean up the <head>っていうのも素晴らしいね。
今回はremoveがfunctionsに書いてあったから必要なかったけど。

でも、SEOにいいよね。headerをスッキリっての。
どれだけSEOに効果があるのか、実際のところはグーグル先生にしかわからないと思うけど。

それで、YoastはSEOをよくするものだし、headerのコメントもいらないよね!SEO的に!
もっと些細なSEOもいいよね!


Yoast のヘッダーのコメントアウトを削除する


で、このコメントアウトを消したいんだが...


<!-- This site is optimized with the Yoast WordPress SEO plugin v' . WPSEO_VERSION . ' - https://yoast.com/wordpress/plugins/seo/ -->

と、


<!-- / Yoast WordPress SEO plugin. -->



まず、②から

吐き出してるソースはこれっぽい。
http://baka★.com/wordpress/wp-content/plugins/wordpress-seo/frontend/class-frontend.php


(560~590辺り)

public function head() {
global $wp_query;

$old_wp_query = null;

if ( ! $wp_query->is_main_query() ) {
$old_wp_query = $wp_query;
wp_reset_query();
}

/**
 * Action: 'wpseo_head' - Allow other plugins to output inside the WP SEO section of the head section.
*/
do_action( 'wpseo_head' );

echo "<!-- / Yoast WordPress SEO plugin. -->\n\n";

if ( ! empty( $old_wp_query ) ) {
$GLOBALS['wp_query'] = $old_wp_query;
unset( $old_wp_query );
}

return;
}


//echo "<!-- / Yoast WordPress SEO plugin. -->\n\n";
コメントアウトでOK。



次、①なんだが...

これが曲者だった。


外人さんのブログhttp://tj.mk/remove-site-optimized-yoast-wordpress-seo-plugin/に

function remove_yoast(){
  global $wpseo_front;
  remove_action( 'wpseo_head', array($wpseo_front, 'debug_marker') , 2 );
}
add_action('wp_enqueue_scripts','remove_yoast'); 

↑をfunctions.phpに書き込めばOKだよって書いてあったのでやってみたら、消えた

・・・

んだけど、これだとYoastで書き換えたSEOタイトルまで消える。


で、次はclass-frontend.phpの45行目辺りに

add_action( 'wpseo_head', array( $this, 'debug_marker' ), 2 );

てのがあるからコメントアウトしてみたが、やっぱり、SEOタイトルまで消える。


タイトル書き換えは使いたいんだYo!


どんな仕組みだYoこれ#となりながら、いろいろ見ていくと見つけた。

class-frontend.phpの1600行目辺りに

$content = str_replace( $this->debug_marker( false ), $this->debug_marker( false ) . "\n" . '<title>' . $title . '</title>', $content );

これを、

$content = str_replace( $this->debug_marker( false ), '<title>' . $title . '</title>', $content );

に書き換えて目的達成。



まあ、①も②もYoastのファイルを直接編集してるからUPDATEとかあったらまた消さないといけないか。


だれかもっとスタイリッシュにできる方法を教えてつかさい。




Yoast header のコメントを削除 まとめ


<!-- This site is optimized with the Yoast WordPress SEO plugin v' . WPSEO_VERSION . ' - https://yoast.com/wordpress/plugins/seo/ -->



Ⅰ YoastのSEOタイトル書き換えを使わない場合


class-frontend.phpの45行目辺りにある、

add_action( 'wpseo_head', array( $this, 'debug_marker' ), 2 );


をコメントアウト。

※これはYoastで設定したSEOタイトルも消える※



Ⅱ YoastのSEOタイトル書き換えを使っている場合


class-frontend.phpの1600行目辺り
$content = str_replace( $this->debug_marker( false ), $this->debug_marker( false ) . "\n" . '<title>' . $title . '</title>', $content );

を、↓のように書き換えればOK。

$content = str_replace( $this->debug_marker( false ), '<title>' . $title . '</title>', $content );


※Yoastで設定したSEOタイトルは消えない※




<!-- / Yoast WordPress SEO plugin. -->



class-frontend.phpの580行目辺りにある、

echo "<!-- / Yoast WordPress SEO plugin. -->\n\n";
をコメントアウト。

コメント

  1. Thank you for sharing valuable information. Nice post. I enjoyed reading this post. The whole blog is very nice found some good stuff and good information here. In addition to this sharing a nice WordPress plugin Widgets for WordPress for users.

    返信削除
  2. Cập nhật link vào Son club chính thức, an toàn và không bị chặn bởi các nhà mạng. Truy cập Son club ngay để tận hưởng không gian cá cược đẳng cấp, nạp rút siêu tốc 1:1 và hỗ trợ khách hàng 24/7.
    Website: https://sonclubb.live/
    Địa chỉ: 253 Dương Đình Cúc, Tân Nhựt, Hồ Chí Minh, Việt Nam
    Điện thoại: 0917 364 528
    Email: support@sonclubb.live
    Hashtag: #sonclub #sonclubcasino #slotgamesonclub #conggamesonclub

    返信削除
  3. Cập nhật link vào nhà cái B52 mới nhất không bị chặn. Hướng dẫn tải app B52 cho điện thoại iOS và Android mượt mà, không giật lag. Khám phá thế giới cá cược casino trực tuyến đỉnh cao.
    Website: https://b52z.org/
    Email: support@b52club.net
    Số điện thoại: 0936 525 252
    Địa chỉ: 236 Lê Thánh Tôn, Phường Bến Thành, Hồ Chí Minh 70000, Vietnam

    返信削除
  4. 123bet là lựa chọn hàng đầu cho người yêu thích cá cược thể thao và casino trực tuyến. Hệ thống bảo mật cao, hỗ trợ 24/7 cùng nhiều chương trình khuyến mãi hấp dẫn mỗi tuần.
    Website: https://123bett.io/
    Địa chỉ: 86-549 Đ. Vĩnh Khánh, Khánh Hội, Hồ Chí Minh, Vietnam
    Điện thoại: 0938493847
    Email: 123bettio@gmail.com
    Hashtag: #123bet #123betoi #game123bet #trangchu123bet #link123bet

    返信削除
  5. Sunwin mang đến không gian cá cược đẳng cấp quốc tế. Khám phá các sảnh bài live casino casino sống động, tỷ lệ ăn thưởng cao nhất thị trường và dịch vụ hỗ trợ khách hàng chuyên nghiệp 24/7.
    Website: https://sun-win.eu.com/
    Địa chỉ: 1/Đội Cấn/43 343, Tổ 5A, Ngọc Hà, Hà Nội, Vietnam
    Điện thoại: 0937836878
    Email: sunwineucom@gmail.com
    Hashtag: #sunwin #taigamesunwin #sunwineucom #linksunwin #trangchusunwin

    返信削除
  6. Hitclub là cổng game bài đổi thưởng đỉnh cao châu Á. Đăng ký tham gia ngay hôm nay để nhận code tân thủ cực giá trị và trải nghiệm kho game slot, tài xỉu xanh chín, bảo mật tuyệt đối.
    Website: https://hitclub1.dev/
    Địa chỉ: 2 Trần Khắc Chân, Tân Định, Hồ Chí Minh, Vietnam
    Điện thoại: 0938938293
    Email: hitclub1dev@gmail.com
    Hashtag: #hitclub #hitclub1dev #taiapphitclub #apphitclub #trangchuhitclub

    返信削除
  7. game bai doi thuong uy tín 2026. Cập nhật link tải chính thức iOS/Android của 10+ cổng game xanh chín. Hệ thống bảo mật thông tin, rút tiền qua ngân hàng, ví điện tử cực nhanh trong 5 phút. Xem ngay!
    Website: https://gamebaidoithuong88.dev/
    Địa chỉ: Hẻm 263 Thạch Lam, Phú Thạnh, Hồ Chí Minh, Vietnam
    Điện thoại: 0937839489
    Email: gamebaidoithuong88dev@gmail.com
    Hashtag: #gamebaidoithuong #gamebaidoithuong88dev #topgamebaidoithuong #topgamedoithuong

    返信削除

コメントを投稿

このブログの人気の投稿

eclipse 改行後のインデントを無効にする

Thunderbird quicktext のデータが消える!治す方法!!

MW WP Form で adminメールにIPを付加