コンテンツ中のテキストを任意のものに置換する

Ads

Code

<?php
function change_any_texts($text){
$replace = array(
//'変更前' => '変更後',
'編集' => '<a href="#">編集</a>',
'削除' => '<strong>削除</strong>'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'change_any_texts');
?>
view raw gistfile1.aw hosted with ❤ by GitHub

Screen shot

Note

Description コンテンツ中のテキストを任意の文字列に置換する。どんなテキストでも置換するので注意
WordPress Ver. 3.3.1
Via replace-keywords