the_content_rss

函式
the_content_rss ( $more_link_text = '(more...)', $stripteaser = 0, $more_file = '', $cut = 0, $encode_html = 0 )
引數
  • (string) $more_link_text Optional. Text to display when more content is available but not displayed. Default '(more...)'.
    Required:
    Default: '(more...)'
  • (int) $stripteaser Optional. Default 0.
    Required:
  • (string) $more_file Optional.
    Required:
    Default: (empty)
  • (int) $cut Optional. Amount of words to keep for the content.
    Required:
  • (int) $encode_html Optional. How to encode the content.
    Required:
相關
  • the_content_feed()
定義位置
相關方法
the_contentthe_content_feedget_the_contentthe_title_rssthe_category_rss
引入
0.71
棄用
2.9.0

the_content_rss – 這個函式用於在RSS feed中顯示一個文章或頁面的內容。它與the_content_feed類似,但輸出結果略有不同。

顯示feed的文章內容。

對於HTML的編碼或$encode_html引數,有三種可能的值。

  • – 0’將使urls成為腳註並使用make_url_footnote()。
  • – 1’將對特殊字元進行編碼,並自動顯示所有的內容。
  • – 2’將從內容中剝離所有HTML標籤。

還要注意,你不能設定字數而不設定HTML編碼。如果是這樣的話,那麼HTML編碼將預設為2,這將剝離所有的HTML標籤。

為了限制內容的字數,你可以使用切割引數。如果內容少於這個數量,那麼就不會有任何點加在結尾。如果有剩餘的內容,那麼將新增圓點,其餘的內容將被刪除。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
_deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' );
$content = get_the_content($more_link_text, $stripteaser);
/**
* Filters the post content in the context of an RSS feed.
*
* @since 0.71
*
* @param string $content Content of the current post.
*/
$content = apply_filters('the_content_rss', $content);
if ( $cut && !$encode_html )
$encode_html = 2;
if ( 1== $encode_html ) {
$content = esc_html($content);
$cut = 0;
} elseif ( 0 == $encode_html ) {
$content = make_url_footnote($content);
} elseif ( 2 == $encode_html ) {
$content = strip_tags($content);
}
if ( $cut ) {
$blah = explode(' ', $content);
if ( count($blah) > $cut ) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
/** @todo Check performance, might be faster to use array slice instead. */
for ( $i=0; $i<$k; $i++ )
$excerpt .= $blah[$i].' ';
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
}
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' ); $content = get_the_content($more_link_text, $stripteaser); /** * Filters the post content in the context of an RSS feed. * * @since 0.71 * * @param string $content Content of the current post. */ $content = apply_filters('the_content_rss', $content); if ( $cut && !$encode_html ) $encode_html = 2; if ( 1== $encode_html ) { $content = esc_html($content); $cut = 0; } elseif ( 0 == $encode_html ) { $content = make_url_footnote($content); } elseif ( 2 == $encode_html ) { $content = strip_tags($content); } if ( $cut ) { $blah = explode(' ', $content); if ( count($blah) > $cut ) { $k = $cut; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } /** @todo Check performance, might be faster to use array slice instead. */ for ( $i=0; $i<$k; $i++ ) $excerpt .= $blah[$i].' '; $excerpt .= ($use_dotdotdot) ? '...' : ''; $content = $excerpt; } $content = str_replace(']]>', ']]&gt;', $content); echo $content; }
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
	_deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' );
	$content = get_the_content($more_link_text, $stripteaser);

	/**
	 * Filters the post content in the context of an RSS feed.
	 *
	 * @since 0.71
	 *
	 * @param string $content Content of the current post.
	 */
	$content = apply_filters('the_content_rss', $content);
	if ( $cut && !$encode_html )
		$encode_html = 2;
	if ( 1== $encode_html ) {
		$content = esc_html($content);
		$cut = 0;
	} elseif ( 0 == $encode_html ) {
		$content = make_url_footnote($content);
	} elseif ( 2 == $encode_html ) {
		$content = strip_tags($content);
	}
	if ( $cut ) {
		$blah = explode(' ', $content);
		if ( count($blah) > $cut ) {
			$k = $cut;
			$use_dotdotdot = 1;
		} else {
			$k = count($blah);
			$use_dotdotdot = 0;
		}

		/** @todo Check performance, might be faster to use array slice instead. */
		for ( $i=0; $i<$k; $i++ )
			$excerpt .= $blah[$i].' ';
		$excerpt .= ($use_dotdotdot) ? '...' : '';
		$content = $excerpt;
	}
	$content = str_replace(']]>', ']]&gt;', $content);
	echo $content;
}

常見問題

FAQs
檢視更多 >