요약글 the_excerpt(); 글자수 제한 > WordPress

본문 바로가기
사이트 내 전체검색

WordPress

요약글 the_excerpt(); 글자수 제한

페이지 정보

profile_image
작성자 최고관리자
댓글 0건 조회 41회 작성일 20-10-20 18:16

본문

[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 );
}

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

접속자집계

오늘
6
어제
9
최대
70
전체
2,977
Copyright © OHPR All rights reserved.