hanuman6
7/13/2013 - 11:44 AM

カスタムフィールドの文字数制限

カスタムフィールドの文字数制限

<?php
    $pattern = '/(^.{10})(.+)/u';
    $subject = post_custom('値の名称');
    $matches = array();
    preg_match($pattern, $subject , $matches);
    if ($matches[2] != '') {
        $out = $matches[1] . '...';
    } else {
        $out = $subject;
    }
    echo($out);
?>