LoginSignup
0
0

More than 5 years have passed since last update.

WordPress記事中の句読点などを半角で出力

Last updated at Posted at 2012-10-14

需要なさそうですが何かのために一応残しておきます。
functions.phpに追記してください。

// 全角句読点を半角にする
function hankaku($replaced)
{
  $pattern1 = array(
    '/\x{3001}/u', // 、
    '/\x{3002}/u', // 。
    '/\x{30FB}/u', // ・
    '/\x{300C}/u', // 「
    '/\x{300D}/u', // 」
    '/\x{FF08}/u', // (
    '/\x{FF09}/u'  // )
  );
  $pattern2 = array(
    '、',
    '。',
    '・',
    '「',
    '」',
    '(',
    ')'
  );
  $replaced = preg_replace($pattern1, $pattern2, $replaced);

  return $replaced;
}
add_filter('the_content', 'hankaku');
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0