2015-01-13 5 views
0

나는 더 많은 것을 읽으려고 노력 해왔다. 발췌 끝에 지금까지 아무런 운이 없었습니다.WP 발췌 부분 끝 부분에 더 많은 내용이 있습니다.

나는 이것을 잘 해내려고 노력했지만, 발췌 부분 하단에 더 많은 것을 읽었다.

the_excerpt(); 
echo '<a class="read-more" href="'. get_permalink(get_the_ID()) . '">Read More...</a>'; 

여기

the_excerpt("Read more.."); 

답변

0

처럼 할 수있는 방법이 당신이 원하는 무엇

function excerpt($limit) { 
     $excerpt = explode(' ', get_the_excerpt(), $limit); 
     if (count($excerpt)>=$limit) { 
     array_pop($excerpt); 
     $excerpt = implode(" ",$excerpt).'...'; 
     } else { 
     $excerpt = implode(" ",$excerpt); 
     } 
     $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt); 
     return $excerpt; 
    } 

    function content($limit) { 
     $content = explode(' ', get_the_content(), $limit); 
     if (count($content)>=$limit) { 
     array_pop($content); 
     $content = implode(" ",$content).'...'; 
     } else { 
     $content = implode(" ",$content); 
     } 
     $content = preg_replace('/\[.+\]/','', $content); 
     $content = apply_filters('the_content', $content); 
     $content = str_replace(']]>', ']]&gt;', $content); 
     return $content; 
    } 

사용법 :

<?php echo excerpt(25); ?> 

출처 : http://bavotasan.com/tutorials/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/

+1

@

<?php echo get_excerpt(); ?> 

은 TBH보다 짧은 코드를 기대했다. – nCore

1

다음을 테마의 functions.php에 입력하십시오.

function new_excerpt_more($more) { 
    return ' <a class="read-more" href="'. get_permalink(get_the_ID()) . '">' . __('Read More', 'your-text-domain') . '</a>'; 
} 
add_filter('excerpt_more', 'new_excerpt_more'); 
+0

이 하나를 시도했지만 더 많은 내용이 표시되지 않습니다. – nCore

+0

이 함수를 테마의 functions.php에 추가해야합니다. –

+0

그래, 제가 알고 있습니다 :) 그러나 발췌문의 끝 부분에는 보이지 않습니다. – nCore

0

당신은 단순히 두 가지 방법을 통해 워드 프레스에 표시 할 수 있습니다 워드 프레스 ::

발췌 (맛보기)에서 제공하는 권장되는 방법을 시도 할 수 있습니다 :

  1. the_content 유지() 템플릿 태그 게시물을 편집 할 때 원하는 "컷오프"지점에 quicktag called more을 삽입하십시오.

  2. the_exceptpt()로 the_content() 템플릿 태그를 대체함으로써.

그리고이

<?php the_content($more_link_text , $strip_teaser); ?>

소스처럼 the_content와 함께 사용되는 매개 변수의 사용을 만들 수있는 "자세히보기"텍스트 링크를 변경

는 => http://codex.wordpress.org/Customizing_the_Read_More

희망이 도움
0

functions.php 파일에 다음 코드를 추가하십시오.

<?php 
// Custom Excerpt 
function excerpt($limit) { 
$excerpt = explode(' ', get_the_excerpt(), $limit); 
if (count($excerpt)>=$limit) { 
array_pop($excerpt); 
$excerpt = implode(" ",$excerpt).'...'; 
} else { 
$excerpt = implode(" ",$excerpt); 
} 
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt); 
return $excerpt; 
} 
?> 

사용법 :

<?php echo excerpt(25); ?> 

출처 : http://www.e2soft.com/blog/custom-excerpt-and-content-limit-wordpress/

0

내가 문자로 제한된 발췌를 표시하는 또 다른 방법이있어. 여기 function.php 파일 코드가 있습니다.

function get_excerpt(){ 
$excerpt = get_the_content(); 
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt); 
$excerpt = strip_shortcodes($excerpt); 
$excerpt = strip_tags($excerpt); 
$excerpt = substr($excerpt, 0, 100); 
$excerpt = substr($excerpt, 0, strripos($excerpt, " ")); 
$excerpt = trim(preg_replace('/\s+/', ' ', $excerpt)); 
$excerpt = $excerpt.'... <a href="'.get_the_permalink().'">Read More</a>'; 
return $excerpt; 
} 

다음은 사용자 정의 된 문자를 문자로 표시하려는 위치를 추가해야합니다. http://www.e2soft.com/forum/question/how-to-set-custom-excerpt-and-content-limit-wordpress/

관련 문제