• RSS

[WP]WordPressでカテゴリリンクを出力した際の title=”に含まれる投稿をすべて表示” を消す方法

  • このエントリーをはてなブックマークに追加
  • follow us in feedly

WordPressでカテゴリリンクを出力する際には、
wp_list_categories()the_category() を利用しますが、

ソースコードには <a title=" の投稿をすべて表示"> も一緒に出力されてしまいます。

この「title=”に含まれる投稿をすべて表示”」の文言を、functions.php をカスタマイズして非表示にさせる方法のご紹介です。

目次

wp_list_categories() によるa title=” に含まれる投稿をすべて表示”」の非表示

wp_list_categories() でカテゴリリンクを出力する場合、functions.php に以下のように記述します。
<?php
add_filter('wp_list_categories', 'remove_category_link_prefix');
function remove_category_link_prefix($output) {
	return str_replace(' に含まれる投稿をすべて表示', '', $output);
}
?>


the_category() によるa title=” の投稿をすべて表示”」の非表示

the_category() でカテゴリリンクを出力する場合、functions.php に以下のように記述します。
<?php
add_filter('the_category', 'remove_the_category_link_prefix');
function remove_the_category_link_prefix($output) {
	return str_replace(' の投稿をすべて表示', '', $output);
}
?>




  • このエントリーをはてなブックマークに追加
  • follow us in feedly

コメント

コメントを残す