While maintaining my Chinese and English WordPress blog, I have always wanted the excerpts in the article lists to display as completely as possible.
The reason is simple: for the homepage, category pages, tag pages, and search result pages, excerpts are not just decoration. Readers usually judge whether an article is relevant to them based on the title and excerpt before deciding whether to enter the detail page. If the excerpt only shows a very short snippet, many articles will be truncated before they can even explain the background and core content, resulting in a poor reading experience.
This problem initially seemed very simple, but the actual troubleshooting process turned out to be much more complicated than I expected.
After a period of actual operation and further verification, I finally confirmed one thing:
Using WPCode to modify the
excerptLengthof the GutenbergPost Excerptblock does indeed allow excerpts in both Chinese and English article lists to display almost completely.
And this has now been verified in practice on the Chinese homepage, Chinese category pages, and English search result pages.
1. The Initial Problem: Chinese Excerpts Were Particularly Prone to Being Too Short
The WordPress Gutenberg Post Excerpt block provides a “Max words” setting.
Initially, I used:
55
But in the actual frontend display, the Chinese excerpts were noticeably too short.
Later, I increased the excerpt length in the theme to:
100
This was already much better than before.
However, what I really wanted to achieve was not just “showing a little more than before”, but rather:
If an article already has a specifically written excerpt, display that excerpt as completely as possible.
This is especially true now that many article excerpts have been specifically generated and refined, serving as a complete article summary in themselves. If the list page only displays the first 100 characters, some information will still be lost.

As seen in the screenshot, the excerpt is already much longer than the initial 55, but it is still truncated in the middle and shows an ellipsis.
This indicates that:
100
is better suited as a fallback value rather than the final target.
2. Increasing the Post Excerpt Length to 500 via WPCode
My final solution was not complicated.
Continuing to use WPCode, I created a new PHP Snippet:
/**
* SWQ:列表页 Post Excerpt 尽量完整显示文章摘要。
*/
add_filter(
'render_block_data',
function ( $parsed_block ) {
if ( 'core/post-excerpt' === ( $parsed_block['blockName'] ?? '' ) ) {
$parsed_block['attrs']['excerptLength'] = 500;
}
return $parsed_block;
},
20
);
The core logic does only one thing:
$parsed_block['attrs']['excerptLength'] = 500;
That is, before the Gutenberg core/post-excerpt block is actually rendered, the excerpt length limit is increased to 500.
For the Chinese and English article excerpts I normally generate now, 500 is already far greater than the actual length of the vast majority of excerpts, so the practical effect is basically equivalent to:
Displaying the existing excerpt in full.
This does not modify the excerpts in the database, nor does it regenerate excerpts; it simply relaxes the display length limit during frontend rendering.
3. Delegating Page Checks to WPCode Instead of Piling Up PHP Conditionals
Initially, I could have also checked the current page in PHP code using:
is_front_page()
is_home()
is_archive()
is_search()
to determine the current page.
However, since WPCode itself already provides Location and Smart Conditional Logic, I preferred to:
Let WPCode decide “where to run”, while the PHP code is only responsible for “what to do after running”.
This keeps the code itself much simpler.

The final settings are:
Insert Method:Auto Insert
Location:Frontend Conditional Logic
This leaves the page scope directly controlled by WPCode.
The PHP code no longer needs to include checks for page types like the homepage, archives, or search pages.
4. Smart Conditional Logic Retains Only Three Types of List Pages
Next, enable:
Enable Logic
Condition selection:
Show
Then create three independent condition groups:
Homepage
OR
Archive
OR
Search Page
The three condition groups are connected using OR.
This means that as long as the current page belongs to any one of them, the Snippet will run.
Homepage
Handles the homepage article list.
Archive
Handles various archive lists, such as:
Category pages
Tag pages
Date archives
Other taxonomy archives
Search Page
Handles internal search results.
I did not include Author Page.
Because my site has already disabled SEO display for author archives, there is no need to specifically maintain this type of list page.
The final responsibilities are thus very clear:
WPCode
│
├── Homepage
├── Archive
└── Search Page
↓
PHP Snippet
↓
core/post-excerpt
↓
excerptLength = 500
5. Why Did I Once Think This Code Was Ineffective?
This is actually the most interesting part of the whole process.
During early testing, I repeatedly toggled:
excerptLength = 500
And even deliberately tested:
excerptLength = 5
But the frontend page once appeared to have no changes at all.
So the troubleshooting scope gradually expanded to:
W3 Total Cache
Object cache
Page cache
CDN
WPCode execution status
Gutenberg block rendering
PHP code cache
Eventually, I even used a temporary MU Plugin specifically to verify the Gutenberg block rendering chain.
At that time, I could confirm:
attrs=5
early=6
late=6
final=6
This meant that excerptLength = 5 itself was actually effective.
5 characters plus an ellipsis resulted in a final length of exactly about 6.
This proved that:
render_block_data → core/post-excerpt → excerptLength
There was no problem with this technical approach itself.
What really complicated the judgment was the multi-layer caching in the production environment and the timing of code updates taking effect.
6. Unexpected Discovery Days Later: The Excerpts Had Actually Been Displaying Completely All Along
The real turning point came a few days later.
I noticed that the excerpts in the article lists on both the Chinese and English websites were actually already displaying almost completely.
I had originally assumed:
This was because the excerpt length in the theme had already been increased from 55 to 100.
Until I later accidentally discovered:
SWQ List pages display full article excerpts
This WPCode Snippet had actually been active the whole time.
So I manually deactivated it.
After a while, I observed the frontend again:
The excerpts reverted to about 100 characters, and obvious truncation reappeared.
This formed a very direct controlled experiment:
WPCode enabled
excerptLength = 500
↓
Excerpts display almost completely
Whereas:
WPCode disabled
↓
Reverts to theme settings
excerptLength = 100
↓
Excerpts truncated again
At this point, it was actually possible to confirm:
What truly caused the article lists to display excerpts in full was this WPCode snippet.
And the 100 in the theme was merely a fallback value for when the snippet was deactivated.
7. Reorganizing the WPCode Configuration and Continuing Observation
After confirming that the code was indeed effective, I re-enabled this Snippet and further organized the configuration into:
Location:
Frontend Conditional Logic
Enable Logic:
On
Conditions:
Homepage
OR Archive
OR Search Page
The code remains minimal:
/**
* SWQ:列表页 Post Excerpt 尽量完整显示文章摘要。
*/
add_filter(
'render_block_data',
function ( $parsed_block ) {
if ( 'core/post-excerpt' === ( $parsed_block['blockName'] ?? '' ) ) {
$parsed_block['attrs']['excerptLength'] = 500;
}
return $parsed_block;
},
20
);
I then stopped immediately clearing the cache frequently and making repeated modifications, instead letting it run naturally in the real production environment for a while.
8. Final Verification 1: Chinese Homepage Excerpts Display Completely
Observing the Chinese homepage again, the excerpts in the list can be seen fully expanded.

For example, the excerpt for the first article on the homepage can now fully explain:
- The Type-C to VGA issue with the ThinkPad T570;
- Why I ultimately gave up on repairing the original link;
- How the new monitor connects directly via HDMI;
- The actual results after restoring the Ubuntu dual-screen setup;
- The final verdict on Thunderbolt and DisplayPort Alt Mode.
If it were still the original 55 or 100 characters, this information would be difficult to fully convey in the article list.
Now, without entering the detail page, readers can already clearly judge:
What problem this article actually solves.
This is exactly the effect I originally hoped to achieve.
9. Final Verification 2: Chinese Category Pages Also Work
Next, I checked the Chinese category pages.

It can be seen that the article excerpts under the category:
Programming Languages
are also fully expanded.
For example:
A Tour of Go Chinese Translation Record: How to translate only the instructional code comments without breaking the Go code
The excerpt can fully introduce:
- The translation page;
- Protection of instructional code comments;
- Protection of Go identifiers;
- Automated validation;
- Manual polishing;
- Final verification results.
This also shows that:
Type of Page → Archive
has correctly covered the category archive pages.
There is no need to separately write PHP conditionals for:
Category
Tag
Taxonomy
.
10. Final Verification 3: English Search Results Also Display Completely
To confirm that this solution was not only effective for Chinese, I also checked the search results page on the English site.

After searching for:
cloudflare
, the English article excerpts can also be seen displaying almost completely.
For example:
WordPress Homepage Still Shows Old Content After Publishing?
Testing EdgeOne and Cloudflare With a 2-Hour Cache for Homepage and Sitemap
The excerpt below can now fully introduce:
- W3 Total Cache;
- EdgeOne;
- Cloudflare;
- Cache duration for the homepage and Sitemap;
- Stale CDN cache issues;
- The final caching strategy adjustments.
The second article about 96-hour cache optimization also fully displayed a longer English excerpt.
This means it has now been verified in practice:
Chinese homepage ✓
Chinese category pages ✓
English search page ✓
And these three types of pages exactly correspond to the currently configured:
Homepage
Archive
Search Page
Therefore, this configuration has formed a complete closed loop.
11. Why Is the Theme Value of 100 Retained?
Although WPCode now uses:
500
I did not revert the:
100
in the theme editor back to 55.
The reason is that this perfectly forms two layers of protection.
Under normal circumstances:
WPCode running normally
↓
500
↓
Existing excerpts display almost completely
If someday in the future, due to:
- WPCode being temporarily deactivated;
- A plugin upgrade;
- The Snippet encountering an error;
- The code being temporarily disabled during debugging;
Then the page will automatically fall back to:
Theme default 100
Instead of reverting to the originally very short:
55
So the current structure can be understood as:
First layer:
WPCode = 500
Responsible for normal full display
Second layer:
Theme = 100
Responsible for reasonable degradation in exceptional cases
This maintenance approach is actually more robust.
12. The Biggest Lesson This Time: Do Not Conclude Code Ineffectiveness Too Early in a Cached Environment
What impressed me the most during this process was not these few lines of PHP.
What is truly worth recording is:
In a WordPress production environment with multiple caching layers, “refreshing the page immediately after modifying code” does not necessarily prove whether the code has taken effect.
Especially since my site simultaneously has:
WordPress
W3 Total Cache
Object cache
Page cache
CDN
WPCode
PHP OPcache
When multiple layers of state overlap, it easily leads to:
Code modified
↓
Immediate refresh
↓
Page still shows old result
↓
Mistakenly assuming code is ineffective
Ultimately, the most convincing part this time was not complex diagnostics, but the simplest long-term comparison:
Enable WPCode
→ Excerpts complete
Disable WPCode
→ Reverts to 100
Re-enable
→ Complete again
Coupled with the actual result verification a few days later on:
Chinese homepage
Chinese category pages
English search page
, the causal relationship was finally confirmed.
13. Final Configuration
This excerpt display solution is now officially established as:
WordPress Theme
Post Excerpt Max words: 100
As a fallback value.
WPCode
Snippet:
SWQ List pages display full article excerpts
Code Type:
PHP Snippet
Insert Method:
Auto Insert
Location:
Frontend Conditional Logic
Enable Logic:
On
Conditions:
Show
Conditions:
Homepage
OR
Archive
OR
Search Page
Code:
/**
* SWQ:列表页 Post Excerpt 尽量完整显示文章摘要。
*/
add_filter(
'render_block_data',
function ( $parsed_block ) {
if ( 'core/post-excerpt' === ( $parsed_block['blockName'] ?? '' ) ) {
$parsed_block['attrs']['excerptLength'] = 500;
}
return $parsed_block;
},
20
);
Summary
The final implementation of this requirement is actually very simple:
Using WPCode, increase
excerptLengthto 500 when rendering the GutenbergPost Excerptblock on specified list pages.
What really took time was the verification process.
After confirming the final real-world operation results, currently:
Chinese homepage Full display ✓
Chinese category pages Full display ✓
English search page Full display ✓
This also proves that the original technical direction was correct.
I am now more inclined to understand the excerpts in article lists as:
A content preview before the article detail page, rather than a piece of decorative text under the title.
Since excerpts have been specifically prepared for articles, readers should be allowed to see the complete information as much as possible before deciding whether to enter the detail page.
At this point, this excerpt display issue, going from 55 to 100 and finally to 500, can officially be brought to a close.

