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.
<?php if ( is_archive() || is_search() || is_home() ) : // Only display excerpts for archives and search. ?>
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 "".
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 :
<?php the_content(__(’(more…)’)); ?>或者<?php the_content(); ?>
2. Modify it to:
The code is as follows:
<?php if(!is_single()) { the_excerpt(); } else { the_content(__(’(more…)’));//或者<?php the_content(); ?> } ?>
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

There are four ways to adjust the WordPress article list: use theme options, use plugins (such as Post Types Order, WP Post List, Boxy Stuff), use code (add settings in the functions.php file), or modify the WordPress database directly.

WordPress IP blocking plugin selection is crucial. The following types can be considered: based on .htaccess: efficient, but complex operation; database operation: flexible, but low efficiency; firewall: high security performance, but complex configuration; self-written: highest control, but requires more technical level.

To log in to a WordPress website account: Visit the login page: Enter the website URL plus "/wp-login.php". Enter your username and password. Click "Login". Verification Two-step Verification (optional). After successfully logging in, you will see the website dashboard.

WordPress Error Resolution Guide: 500 Internal Server Error: Disable the plug-in or check the server error log. 404 Page not found: Check permalink and make sure the page link is correct. White Screen of Death: Increase the server PHP memory limit. Database connection error: Check the database server status and WordPress configuration. Other tips: enable debug mode, check error logs, and seek support. Prevent errors: regularly update WordPress, install only necessary plugins, regularly back up your website, and optimize website performance.

Enable comments in WordPress website: 1. Log in to the admin panel, go to "Settings" - "Discussions", and check "Allow comments"; 2. Select a location to display comments; 3. Customize comments; 4. Manage comments, approve, reject or delete; 5. Use <?php comments_template(); ?> tags to display comments; 6. Enable nested comments; 7. Adjust comment shape; 8. Use plugins and verification codes to prevent spam comments; 9. Encourage users to use Gravatar avatar; 10. Create comments to refer to

A step-by-step guide to replacing a header image of WordPress: Log in to the WordPress dashboard and navigate to Appearance >Theme. Select the topic you want to edit and click Customize. Open the Theme Options panel and look for the Site Header or Header Image options. Click the Select Image button and upload a new head image. Crop the image and click Save and Crop. Click the Save and Publish button to update the changes.

The steps to create a custom header in WordPress are as follows: Edit the theme file "header.php". Add your website name and description. Create a navigation menu. Add a search bar. Save changes and view your custom header.

To build a website using WordPress hosting, you need to: select a reliable hosting provider. Buy a domain name. Set up a WordPress hosting account. Select a topic. Add pages and articles. Install the plug-in. Customize your website. Publish your website.
