YARPPが読み込むCSSを削除する方法

2017年5月28日Wordpress

この記事のURLとタイトルをコピー
お使いの端末ではこの機能に対応していません。
下のテキストボックスからコピーしてください。

どーも!カゴブロ(@kagoblo)です。

記事下に関連記事を挿入するためにWordPressプラグイン「Yet Another Related Posts Plugin (YARPP)」をインストールしました。

現在カゴブロで使っているテーマ「Luxeritas」でもデフォルトで関連記事が表示されますが、同一カテゴリ内からランダムで表示される仕様です。
今後カテゴリ整理をうまく行っていける自信がないため、カテゴリを超えてコンテンツ本文での関連記事を表示したくYARPPをインストールしました。

以下の内容を子テーマのfunctions.phpに追記すればOK!

// YARPPのwidget.cssを削除
add_action('wp_print_styles','crunchify_dequeue_header_styles');
function crunchify_dequeue_header_styles()
{
  wp_dequeue_style('yarppWidgetCss');
}
 
// YARPPのrelated.cssを削除
add_action('get_footer','crunchify_dequeue_footer_styles');
function crunchify_dequeue_footer_styles()
{
  wp_dequeue_style('yarppRelatedCss');
}

上記の内容をfunctions.phpに追記してください。

消えてるか確認

head内の

<link rel="stylesheet" id="yarppWidgetCss-css" href="//kagoblo.net/wp-content/plugins/yet-another-related-posts-plugin/style/widget.css" media="all">

及び、</body>上の

<link rel="stylesheet" id="yarppRelatedCss-css" href="//kagoblo.net/wp-content/plugins/yet-another-related-posts-plugin/style/related.css" media="all">

が読み込まれていないのを確認できたらOKです。

参考にしたページ