요약글 the_excerpt(); 글자수 제한
페이지 정보

본문
[functions.php]
function stacker_custom_wp_trim_excerpt( $text )
{
$raw_excerpt = $text;
if ( '' == $text ) {
//Retrieve the post content.
$text = get_the_content( '' );
$text = strip_shortcodes( $text );
$text = apply_filters( 'the_content', $text );
$text = str_replace( ']]>', ']]>', $text );
// the code below sets the excerpt length to 55 words. You can adjust this number for your own blog.
$excerpt_length = apply_filters( 'excerpt_length', 55 );
// the code below sets what appears at the end of the excerpt, in this case ...
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '...' );
$words = preg_split( "/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY );
if ( count( $words ) > $excerpt_length ) {
array_pop( $words );
$text = implode( ' ', $words );
$text = force_balance_tags( $text );
$text = $text . $excerpt_more;
} else {
$text = implode( ' ', $words );
}
}
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
}
function stacker_custom_wp_trim_excerpt( $text )
{
$raw_excerpt = $text;
if ( '' == $text ) {
//Retrieve the post content.
$text = get_the_content( '' );
$text = strip_shortcodes( $text );
$text = apply_filters( 'the_content', $text );
$text = str_replace( ']]>', ']]>', $text );
// the code below sets the excerpt length to 55 words. You can adjust this number for your own blog.
$excerpt_length = apply_filters( 'excerpt_length', 55 );
// the code below sets what appears at the end of the excerpt, in this case ...
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '...' );
$words = preg_split( "/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY );
if ( count( $words ) > $excerpt_length ) {
array_pop( $words );
$text = implode( ' ', $words );
$text = force_balance_tags( $text );
$text = $text . $excerpt_more;
} else {
$text = implode( ' ', $words );
}
}
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
}
- 이전글특성 이미지 포스트 링크 자동 추가 24.11.04
- 다음글본물글에서 이미지 제거 20.10.20
댓글목록
등록된 댓글이 없습니다.