外掛說明
This plugin adds several improvements to WordPress’ default way of creating excerpts.
- Keeps HTML markup in the excerpt (and you get to choose which tags are included)
- Trims the excerpt to a given length using either character count or word count
- Only the ‘real’ text is counted (HTML is ignored but kept)
- Customizes the excerpt length and the ellipsis character that are used
- Completes the last word or sentence in an excerpt (no weird cuts)
- Adds a read-more link to the text
- Ignores custom excerpts and use the generated one instead
- Theme developers can use
the_advanced_excerpt()
for even more control (see the FAQ)
Most of the above features are optional and/or can be customized by the user or theme developer.
Banner image credit – chillihead
Original plugin author – basvd
實用資源
螢幕擷圖
安裝方式
- 請使用自動安裝方式安裝。
- 前往 [設定]→[內容摘要] 進行設定。
常見問題集
-
什麼是內容摘要?
-
內容摘要是文章的簡短內容提要,一般用於顯示大量文章的頁面 (例如搜尋結果、新聞資訊提供、彙整)。使用者撰寫內容時可以自動內容摘要,但是如果略過自訂,WordPress 會自行產生內容摘要。
-
如何判斷網站是否需要這個外掛?
-
WordPress 自動產生的內容摘要預設會移除全部 HTML 標籤。如果網站使用的佈景主題使用
the_excerpt()
或the_content()
以檢視內容摘要,由於移除了表情符號或清單失去階層性等,內容摘要可能看起來會不如預期;如果使這個外掛,便能修正這些問題,並能讓使用者對內容摘要有更多的控制權。 -
這個外掛是否有 WordPress 核心程式最低版本要求?
-
在開發階段,這個外掛已通過 WordPress 近期多個最新版本環境的測試。這個外掛或許能在舊版 WordPress 上使用,但仍建議網站管理員將網站更新至最新版本。
-
這個外掛是否能本地化為我的母語版本?
-
Advanced Excerpt 符合國際化 (I18N) 規範。
-
這個外掛是否支援多位元組字元,例如中文?
-
這個外掛在 4.1 之前的版本,提供對多位元組字元的直接支援。這項功能不該由特定外掛進行支援,因此目前已移除這項功能的程式碼。
如果網站需要多位元組字元的支援,網站管理員可以在 PHP 中覆寫預設文字作業。
-
Can I manually call the filter in my WP theme or plugin?
-
The plugin automatically hooks on
the_excerpt()
andthe_content()
functions and uses the parameters specified in the options panel.If you want to call the filter with different options, you can use
the_advanced_excerpt()
template tag provided by this plugin. This tag accepts query-string-style parameters (theme developers will be familiar with this notation).The following parameters can be set:
length
, an integer that determines the length of the excerptlength_type
, enumeration, if set towords
the excerpt length will be in words; if set tocharacters
the excerpt length will be in charactersno_custom
, if set to1
, an excerpt will be generated even if the post has a custom excerpt; if set to0
, the custom excerpt will be usedno_shortcode
, if set to1
, shortcodes are removed from the excerpt; if set to0
, shortcodes will be parsedfinish
, enumeration, if set toexact
the excerpt will be the exact lenth as defined by the “Excerpt Length” option. If set toword
the last word in the excerpt will be completed. If set tosentence
the last sentence in the excerpt will be completed.ellipsis
, the string that will substitute the omitted part of the post; if you want to use HTML entities in the string, use%26
instead of the&
prefix to avoid breaking the queryread_more
, the text used in the read-more linkadd_link
, if set to1
, the read-more link will be appended; if0
, no link will be addedallowed_tags
, a comma-separated list of HTML tags that are allowed in the excerpt. Entering_all
will preserve all tags.exclude_tags
, a comma-separated list of HTML tags that must be removed from the excerpt. Using this setting in combination withallowed_tags
makes no sense
A custom advanced excerpt call could look like this:
the_advanced_excerpt('length=320&length_type=words&no_custom=1&ellipsis=%26hellip;&exclude_tags=img,p,strong');
-
Does this plugin work outside the Loop?
-
No, this plugin fetches the post from The Loop and there is currently no way to pass a post ID or any custom input to it.
However, you can start The Loop manually and apply the plugin as usual.
使用者評論
參與者及開發者
變更記錄
4.4.1 (January 19th, 2024)
- Fix – PHP 8 issue with “creation of dynamic property” being deprecated
4.4.0 (February 1st, 2023 )
- New – Option to generate an excerpt from the manually created excerpt (instead of showing full manual excerpt)
4.3.9 (April 13th, 2021)
- New – Option to enable adding the “read more link” for custom excerpts as well
4.3.8 (December 28th, 2020)
- New – Multilanguage compatibility for the “read more” text. The shortcode [advanced_excerpt_text] is used. Example [advanced_excerpt_text lang=”en_US”]English[/advanced_excerpt_text][advanced_excerpt_text lang=”de_DE”]German[/advanced_excerpt_text]
4.3.7 ( July 10th, 2020 )
- New – Option to link the whole excerpt to the single post page
- Fix – Issue with “sentence finish” when there is a number with decimal points
- Fix – Updated POT file for translations
4.3.6 ( June 1st, 2020 )
- Fix – Issue with undefined index PHP notice
4.3.5 ( February 6th, 2020 )
- Fix – Issue when excerpt ends in a foreign character
4.3.4 ( December 17th, 2019 )
- Fix – Sentence finish option not working properly if . ? or ! are followed by another character such as ” for example
4.3.3 ( October 5th, 2019 )
- Fix – Conflict with “WPTouch” plugin
- Fix – Conflict with “bbPress” plugin
4.3.2 ( September 24th, 2019 )
- Fix – Conflict with “The Events Calendar” plugin
4.3.1 ( June 21st, 2019 )
- New – Option to disable the functionality for WooCommerce products
4.3.0 ( June 14th, 2019 )
- Fix – Conflict with Sassy Social Share plugin
4.2.9 ( May 27th, 2019)
- New – Filter for developers to change the read more text. The filter is advanced_excerpt_read_more_text
- Tweak – The read more text option now accept shortcodes
4.2.8
- New – Screen reader text is now optional, can be enabled in the options
- New – Added option to remove the “read more link” if the full post content is shown
- New – Title can be included in the “read more link” by adding {title} to the option
4.2.7
- New – Option to open “read more” in a new tab
- New – Added screen reader text for “read more” link
4.2.6
- New “Finish” option that counts exact characters including blank spaces.
4.2.5
- Fixed the “remove shortcodes from excerpt” functionality
4.2.4
- Compatibility tested for latest version of WordPress ( 4.9.6 )
- Minor tweaks
4.2.3
- Fix: The “Remove all tags except the following” wasn’t excluding tags as expected
- Fix: Call
remove_all_filter()
on thethe_excerpt
hook to improve excerpt rendering - Fix: Only honor the “Only filter
the_content()
when there’s no break (<!–more–>) tag in the post content” setting when hooking intothe_content
filter - Improvement: Improve backwards compatibility by reverting back to using
get_the_content()
for the base excerpt text - Improvement: Added the
advanced_excerpt_skip_excerpt_filtering
filter allowing users to skip excerpt filtering on a per excerpt basis
4.2.2
- Fix: The
the_advanced_excerpt()
function was not working on singular page types (pages / posts)
4.2.1
- Fix: Undefined index errors when using the
the_advanced_excerpt()
function - Fix: Not excluding tags when using the
exclude_tags
argument in thethe_advanced_excerpt()
function
4.2
- Feature: Toggle excerpt filtering when there’s no break (<!–more–>) tag in the post content
- Feature: Toggle excerpt filtering for the
the_excerpt()
andthe_content()
functions - Feature: Toggle excerpt filtering on certain page types
- Improvement: Added HTML5 tags to the allowed tags list
- Improvement: Options are now automatically removed from
wp_options
when the plugin is deleted from the dashboard - Improvement: Added several WordPress filters, allowing developers to extend/modify the default functionality of the plugin
- Improvement: Additional strings were made i18n friendly
- Improvement: All options are now stored in one row in wp_options rather than one row per option
- Improvement: Several UI elements have be reworded and styled differently to improve user experience
- Fix: Now works with themes using
the_content()
on archive pages (i.e. WordPress default themes and others) - Fix: Notices/warning were appearing when the options were saved while having a checkbox option unchecked
- Fix: The “Read More” link was being incorrectly appended into certain HTML tags, e.g. table tags and list tags
4.1
- Fix: Template function with custom options works again
- Fix: Data before header bug (retro-fixed in 4.0)
- Feature: Template function also works with array-style parameters
- Removed multibyte support
- Removed PHP 4 support (WP 3.2+ users should be fine, others should update)
- Better code testing before release!
4.0
- Feature: Brand new parsing algorithm which should resolve some running time issues
- Feature: Options to finish a word or sentence before cutting the excerpt
- Fix: A few small bugs
3.1
- Fix: A few bugs with custom and character-based excerpts
3.0
- First major release since 0.2.2 (also removed the
0.
prefix from the version number) - Feature: Shortcodes can be removed from the excerpt
- Feature: Virtually any HTML tag may now be stripped
- Feature: A read-more link with custom text can be added
- Fix: Word-based excerpt speed improved
- Fix: Template tag function improved
- Fix: Better ellipsis placement