Home>Article>CMS Tutorial> How to set up WordPress post excerpts
The following are four ways to display article summaries in WordPress:
1. Use WordPress’s own summary function
I currently use this method on another WordPress blog, and the display effect is also very satisfactory. The only drawback is that I need to set a separate summary when writing an article. However, this point must be viewed dialectically. Although it is a bit troublesome, it has good flexibility.
Usage setting method:
1. Click "Show Options" in the upper right corner of the article editing page, check the "Abstract" option inside, and write the summary content separately when writing articles in the future. Can.
2. After the article is published, you may see that the full text is still output on the home page, while the summary is displayed on the archive pages such as categories and tags. We can use the following methods to solve the problem.
3. In the WordPress backend "Appearance" - "Edit", click to modify the loop.php file, about line 137, find and modify the following sentence, add a home page applicable judgment, the red font is Add section.
4. After setting, the home page will be displayed in summary like other archive pages.
Related recommendations: "WordPress Tutorial"
2. Insert the "more" separation tag
1. This is also a setting that comes with WordPress One of the summary methods is to insert the "more" separation tag after the intercepted summary text when editing the article, click the "more" separation icon in the editor above, or you can directly write the label statement "bf24f777d1d65c17e41632e59bfb348b".
2. After setting, the homepage and other archive pages will be displayed like a summary, and a "Continue Reading →" link will be automatically added after the summary. However, if you look closely at this link, you may find that #more-id is added at the end. It is a content jump anchor link. Clicking it will go to the summary content to continue reading.
3. Whether to remove this anchor point jump depends on personal preference. If you want to remove it, in the WordPress backend "Appearance" - "Edit", click to modify the functions.php file, copy and add the following code. The meaning of the code is to use the filter of WordPress the_content_more_link, and use it with a regular expression to replace the string in the form of #more-id in the link with nothing.
The code is as follows:
function remove_more_jump_link($link) { return preg_replace('/#more-\d+/i','',$link); } add_filter('the_content_more_link', 'remove_more_jump_link');
3. Modify the theme index.php file
1. Open the folder where you are using the theme, find the index.php file, and find the following code :
或者
2. Modify it to:
The code is as follows:
} ?>
3. After saving, the article can automatically intercept the abstract, but the disadvantage is that the format in the abstract will Disappear, such as bold text, font color, etc.
4. Use summary plug-ins
Although there are some aspects of WordPress that are not suitable for our use, fortunately, there are many plug-ins, and there are many plug-ins that automatically set article abstracts. Here are a few that are easier to use. of.
1. WP-UTF8-Excerpt: supports multi-byte languages (such as Chinese), will not produce garbled characters and retains the format.
2. WP-Posts Auto Cutter: UTF-8 interception method is used to prevent Chinese garbled characters and retain the summary format. The author of this plug-in has not submitted it to WordPress. You can only download it from the author's homepage: http://blog.netdll.com/?p=1276 (the website is blocked).
3. Limit Posts Automatically: Mainly used for English sites, and errors will occur if used in Chinese
The above is the detailed content of How to set up WordPress post excerpts. For more information, please follow other related articles on the PHP Chinese website!