2010-12-19 35 views

回答

0

走在WP源一看,該功能位於wp-includes/post-template.php周圍線200在get_the_content功能

我不會建議只是複製和粘貼,因爲它很可能將無法正常工作,但你可能會得到它背後的邏輯。 WP採用了<!--more -->標籤的preg_match,那麼如果它存在解析吧..

$content = $pages[$page-1]; 
if (preg_match('/<!--more(.*?)?-->/', $content, $matches)) { 
      $content = explode($matches[0], $content, 2); 
      if (!empty($matches[1]) && !empty($more_link_text)) 
       $more_link_text = strip_tags(wp_kses_no_null(trim($matches[1]))); 

      $hasTeaser = true; 
     } else { 
// so on 
3

使用CodeIgniter中包含的Text Helper中的word_limiter()函數將您的帖子縮短爲固定數量的單詞,然後將「read more」超鏈接附加到該文本並回顯。

Text Helper Reference

+0

感謝更多的功能和怎麼樣? – nina 2010-12-19 10:30:51

+0

echo'read more' – Shivaas 2010-12-20 03:28:02

相關問題