Last active
March 22, 2018 02:49
-
-
Save kobaatsu/f1124b2127295c8961e3069f7648a053 to your computer and use it in GitHub Desktop.
[タイトルを以下略] #wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_abbreviated_title($post_id, $num_char = 20, $ellips = '…') { | |
$title = get_the_title($post_id); | |
if ( mb_strlen($title, 'UTF-8') > $num_char ) { | |
$title = mb_substr($title, 0, $num_char, 'UTF-8') . $ellips; | |
} | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment