After migrating the WordPress English site from www.shuijingwanwq.com/en/ to the independent subdomain en.shuijingwanwq.com, the English article pages and homepage became accessible. However, upon further inspecting the homepage and category archive pages, I found that links generated by some blocks still pointed to the Chinese main domain or the old /en/ path.
The most obvious issue was the category dropdown list on the English homepage. After selecting the Browser category, the browser did not visit the English category page, but instead went to:
https://www.shuijingwanwq.com/?category_name=browser-en
This ultimately returned a 404.
Further investigation revealed that this was not an isolated link issue, but rather involved the category dropdown list, site title, footer menu, English navigation, breadcrumbs, and hardcoded links across different templates.
This article documents the entire inspection, repair, and verification process.
1. Current Multi-Domain Structure
The site uses WordPress, Polylang, Twenty Twenty-Five, and W3 Total Cache.
The current language and domain mapping is as follows:
Chinese site:
https://www.shuijingwanwq.com/
English site:
https://en.shuijingwanwq.com/
The English site was previously located at:
https://www.shuijingwanwq.com/en/
After completing the subdomain migration, Nginx still retains the 301 compatibility rule for the old /en/ path. Therefore, some old links still work but require an extra redirect.
Previously, I also troubleshot an issue where English calendar links were concatenated into double URLs:
https://www.shuijingwanwq.com/2026/07/11/19354/
The issue discovered this time shares similarities with the calendar issue: the block content was already recognized as English, but some dynamic links still used the WordPress default Chinese site homepage address.
2. Initial Discovery: English Category Dropdown Returns 404
After selecting Browser from the category dropdown list on the English homepage, the browser redirected to:
https://www.shuijingwanwq.com/?category_name=browser-en
The response status was:
404
However, the correct query address for the English category should be:
https://en.shuijingwanwq.com/?category_name=browser-en
Which further redirects to the formal category archive:
https://en.shuijingwanwq.com/category/application-tool-en/browser-en/
And returns a 200 normally.
This indicates that:
- The English category slug
browser-enis correct; - The category data itself is not lost;
- The permalink rules are not broken;
- The actual error is that the category dropdown list uses the Chinese main domain.
3. Inspecting the Category Dropdown Block
Locating the “Categories” block in the theme editor shows that it uses the WordPress categories and has “Display as dropdown” enabled.
![[Figure 1, Categories block and "Display as dropdown" setting in the theme editor]](https://media.shuijingwanwq.com/2026/07/1-37-1024x532.png)
This block allows configuring:
- Whether to display as a dropdown;
- Whether to show post counts;
- Whether to show only top-level terms;
- Whether to show empty terms;
- Whether to show hierarchy.
However, there is no option to set the redirect domain.
The category options output by the English page are correct:
<option value="browser-en">Browser (32)</option>
The problem lies in the dropdown redirect script automatically generated by WordPress:
[
"wp-block-categories-1",
"https://www.shuijingwanwq.com"
]
When the user selects Browser, the script concatenates the category slug to the Chinese homepage:
https://www.shuijingwanwq.com/?category_name=browser-en
The English homepage outputs a total of 742 category options, of which 735 category slugs end with -en. Therefore, this is not an error with a single category, but a domain error affecting the entire English category dropdown list.
4. Why Not Globally Modify home_url()
A seemingly straightforward solution would be to globally modify WordPress’s home_url() to the English domain when a request comes from en.shuijingwanwq.com.
This approach might fix some dynamic links, but it cannot fix all issues.
Links on the site fall into two main categories.
1. Dynamically Generated Links
For example:
- Category dropdown list;
- Site title;
- Breadcrumb Home;
- Some search, archive, and block links.
These links might call home_url() or similar functions during rendering.
2. Hardcoded Links Saved in Blocks or Navigation
For example:
https://www.shuijingwanwq.com/en/
Or:
/en
These links are already written into navigation blocks, paragraphs, or template content. Globally modifying home_url() will not automatically rewrite them.
At the same time, globally filtering home_url() could also affect:
- REST API;
- Login and logout redirects;
- AJAX requests;
- Form submissions;
- Admin previews;
- Plugin callback URLs;
- Polylang domain detection;
- W3 Total Cache cache keys.
Therefore, I ultimately adopted an approach of “targeted fixes for dynamic links + item-by-item modification of hardcoded links.”
5. First Attempt: Using render_block_core/categories
I initially tried to filter the category block output via render_block_core/categories to replace the Chinese homepage with the current language’s homepage.
However, inspecting the origin server’s dynamic response revealed that the category redirect script automatically generated by WordPress was not within the block HTML that the filter could modify.
The relevant JavaScript was only appended to the page after the filter had finished executing.
As a result, the page still output:
[
"wp-block-categories-1",
"https://www.shuijingwanwq.com"
]
This attempt did not take effect.
6. Second Attempt: Using PHP Output Buffering to Replace Final HTML
I subsequently tried starting output buffering in template_redirect to perform a regex replacement on the category script within the final HTML.
However, under the current W3 Total Cache output buffering environment, the replacement still did not appear in the final response.
Even when using:
- Cloudflare MISS requests;
- Requests with unique query parameters;
- POST dynamic requests;
The final HTML still retained the original Chinese domain.
This indicates that directly rewriting the complete HTML is not stable enough under the current caching and output buffering combination.
7. Final Solution: Taking Over the Category Dropdown Event on the Frontend
Ultimately, instead of continuing to modify the original WordPress script, I opted to take over the change event when the category dropdown list changes.
I created a new WPCode PHP snippet:
Fix category dropdown redirect domain for non-default language sites
The final code is as follows:
add_action(
'wp_footer',
function () {
?>
<script id="swq-fix-category-dropdown-domain">
document.addEventListener('DOMContentLoaded', function () {
document
.querySelectorAll(
'select[name="category_name"][id^="wp-block-categories-"]'
)
.forEach(function (dropdown) {
dropdown.addEventListener(
'change',
function (event) {
if (
!dropdown.value ||
dropdown.value === '-1'
) {
return;
}
event.stopImmediatePropagation();
const url = new URL(
window.location.origin
);
url.searchParams.set(
dropdown.name,
dropdown.value
);
window.location.href = url.href;
},
true
);
});
});
</script>
<?php
},
100
);
WPCode is configured as:
Code Type:PHP Snippet
Insert Method:Auto Insert
Location:Run Everywhere
Status:Active
Although the Location uses Run Everywhere, the code hooks into:
wp_footer
It only outputs the patch on frontend pages that call wp_footer(), and will not output it in the WordPress admin via admin_footer.
This code does not hardcode the English domain, but uses:
window.location.origin
Therefore:
- The Chinese site automatically uses
https://www.shuijingwanwq.com; - The English site automatically uses
https://en.shuijingwanwq.com; - Adding other language domains in the future will also adapt automatically.
8. WPCode Enabled, but English Domain Does Not Load the Code
After enabling the snippet, the inspection results initially showed:
www.shuijingwanwq.com: patch output normal
en.shuijingwanwq.com: patch not output
This indicates that the code itself has no syntax issues and the WPCode snippet is enabled, but the English domain is still reading the old object cache.
This is consistent with the W3 Total Cache Object Cache issue previously encountered in the Polylang multi-domain environment.
Using the previously prepared script to clear the object cache by Host:
/root/bin/w3tc-flush-host-object-cache \
en.shuijingwanwq.com
Execution result:
Started WordPress with the following Host, and called W3TC Object Cache cleanup:
en.shuijingwanwq.com
After flushing the English Host’s object cache, the English origin server finally output:
<script id="swq-fix-category-dropdown-domain">
The real browser test result was:
Select Browser
→ https://en.shuijingwanwq.com/category/application-tool-en/browser-en/
→ 200
The category dropdown issue was successfully fixed.
9. Continuing to Inspect Other Links on the English Homepage
After fixing the category dropdown, I continued to inspect all standard links and dynamic controls on the English homepage.
The inspection scope included:
- Standard
<a>links; - Category dropdown list;
- Archives dropdown list;
- Header navigation;
- Footer navigation;
- Site title;
- Calendar;
- Pagination;
- Search form;
- Chinese-English language switcher.
I subsequently discovered several more old links.
10. Fixing the Footer Blog Link
The Blog link in the English footer was originally:
https://en.shuijingwanwq.com/en
This address did not lead to the English homepage; instead, it was recognized by WordPress as a content slug, ultimately redirecting to a 2019 article:
https://en.shuijingwanwq.com/2019/07/17/15210/
In the footer template component, you can see that the Chinese and English menus are controlled by two separate Language Visibility blocks.
![[Figure 2, Chinese and English Language Visibility menus in the footer template]](https://media.shuijingwanwq.com/2026/07/2-36-1024x485.png)
The English Blog used a custom link:
/en
I changed it to:
/
![[Figure 3, Changing the English footer Blog link from /en to /]](https://media.shuijingwanwq.com/2026/07/3-35-1024x485.png)
After saving the template and flushing the English Host’s object cache, the English origin server output changed to:
<a href="/" target="_blank">
<span>Blog</span>
</a>
It now goes directly to the current English domain homepage.
11. Fixing the Header and Footer Site Titles
Both the header and footer Yongye site titles on the English page originally pointed to:
https://www.shuijingwanwq.com/
Clicking them led to the Chinese homepage.
Inspecting the “Site Title” block in the theme editor revealed only the following options on the right:
- Link title to home;
- Open in new window.
There was no option to manually set the homepage URL.
![[Figure 4, Site Title block only allows setting whether to link to home]](https://media.shuijingwanwq.com/2026/07/4-35-1024x485.png)
Therefore, I created a new WPCode snippet to fix the multi-domain homepage links.
The breadcrumb Home later presented the same issue, so the final snippet name was adjusted to:
Fix multi-domain dynamic homepage links
The final code is as follows:
add_action(
'wp_footer',
function () {
?>
<script id="swq-fix-multidomain-home-links">
document.addEventListener('DOMContentLoaded', function () {
document
.querySelectorAll(
[
'.wp-block-site-title a',
'.wp-block-breadcrumbs ol > li:first-child a'
].join(',')
)
.forEach(function (link) {
link.href = window.location.origin + '/';
});
});
</script>
<?php
},
100
);
WPCode is configured as:
Code Type:PHP Snippet
Insert Method:Auto Insert
Location:Run Everywhere
Status:Active
It uniformly corrects the site title and breadcrumb homepage links to the homepage of the domain the current page resides on.
English page verification results:
Header Yongye
→ https://en.shuijingwanwq.com/
Footer Yongye
→ https://en.shuijingwanwq.com/
12. Fixing the Header English Home Menu
The Home link in the English header navigation was originally associated with the old English homepage page:
https://www.shuijingwanwq.com/en/
![[Figure 5, English main menu Home still associated with the old /en page]](https://media.shuijingwanwq.com/2026/07/5-29-1024x422.png)
Although Nginx can 301 redirect it to the English subdomain, this incurs an unnecessary redirect.
In the English main menu, I changed Home to a custom relative link:
/
![[Figure 6, English Home menu modified to relative path /]](https://media.shuijingwanwq.com/2026/07/6-25-1024x422.png)
After saving and flushing the English Host’s object cache, the origin server output changed to:
<a href="/">Home</a>
13. Fixing About Me & Contact on the Blog Homepage
The link in the personal branding area of the English blog homepage was originally:
https://www.shuijingwanwq.com/en/about-me-contact-2/
This content is located within an English-specific Language Visibility block, so it can be modified independently without affecting the Chinese links.
![[Figure 7, Old About Me & Contact link in English Language Visibility]](https://media.shuijingwanwq.com/2026/07/7-16-1024x444.png)
I changed it to:
/about-me-contact-2/
After saving and flushing the English Host’s object cache, the English origin server output:
<a href="/about-me-contact-2/">
👉 About Me & Contact
</a>
14. Inspecting the English Category Archive Page
After completing the fixes on the English homepage, I continued to inspect:
https://en.shuijingwanwq.com/category/programming-language-en/
Basic inspection results:
HTTP: 200
lang: en-US
canonical: https://en.shuijingwanwq.com/category/programming-language-en/
Page title: Programming Language Category Archives - Yongye
H1: Category: Programming Language
Pagination links also correctly used the English domain:
https://en.shuijingwanwq.com/category/programming-language-en/page/2/
After actually selecting Browser from the category dropdown list, it also successfully entered:
https://en.shuijingwanwq.com/category/application-tool-en/browser-en/
15. Two Separate Issues Discovered on the Category Page
Although the English homepage was functioning normally, the category archives use the “All Archives” template, so two old links remained:
- The breadcrumb Home pointed to the Chinese homepage;
- The About Me & Contact link in the category template sidebar still pointed to the old
/en/address.
This shows that different templates in a WordPress block theme can contain block content that appears identical but is actually independent of each other.
Modifying the Blog Homepage template does not automatically modify the All Archives template.
16. Fixing the Breadcrumb Home
The breadcrumb block in the theme editor can only be configured with:
- Whether to show the homepage breadcrumb;
- Whether to show the current page;
- The separator.
![[Figure 8, Breadcrumb settings in the All Archives template]](https://media.shuijingwanwq.com/2026/07/8-14-1024x314.png)
It has no homepage URL setting.
The frontend structure is:
<nav class="wp-block-breadcrumbs">
<ol>
<li>
<a href="https://www.shuijingwanwq.com/">
Home
</a>
</li>
</ol>
</nav>
Therefore, I added .wp-block-breadcrumbs to the previous “Fix multi-domain dynamic homepage links” code snippet.
After the fix:
Breadcrumb Home
→ https://en.shuijingwanwq.com/
17. Fixing the About Link in the All Archives Template
In the “All Archives” template, I located the About Me & Contact under the English Language Visibility, and changed:
https://www.shuijingwanwq.com/en/about-me-contact-2/
To:
/about-me-contact-2/
I saved the template and flushed the English Host’s object cache again.
18. Final Verification Results
I conducted a final review of the English homepage and English category archive pages.
English category page:
https://en.shuijingwanwq.com/category/programming-language-en/
The final results are as follows:
HTTP status: 200
Page language: en-US
canonical: Correct
H1: Category: Programming Language
Breadcrumb Home: English homepage
Header Yongye: English homepage
Footer Yongye: English homepage
Header Home: English homepage
Footer Blog: English homepage
About Me & Contact: English page
Category dropdown list: Normal
Category pagination: Normal
Broken link statistics:
Incorrectly pointing to www Chinese domain: 0
Old www/en/ paths: 0
en.shuijingwanwq.com/en: 0
The only link on the page still pointing to www.shuijingwanwq.com is:
中文(中国)
This is the expected language switcher link.
19. Cloudflare Cache Handling Strategy
During the repair process, old pages already cached in Cloudflare will not immediately include the new code.
Because the category dropdown list, site title, and sidebar exist across a large number of pages, purging URLs one by one would be highly labor-intensive.
The strategy ultimately adopted was:
- Confirm that the English origin server’s dynamic response is already correct;
- Use POST, unique query parameters, or cache MISS requests to verify the new output;
- Do not purge the entire Cloudflare cache;
- Let existing page caches expire naturally;
- Newly generated or expired pages will automatically include the patch.
Therefore, during the transition period, a small number of old cached pages might still temporarily display old links, but this will not affect the final state of the origin server.
20. Lessons Learned from This Troubleshooting
1. Completing a Multi-Domain Migration Does Not Mean All Template Links Have Migrated
Even if Polylang, Nginx, canonical, and article links are all functioning correctly, block templates might still retain:
- Old absolute URLs;
- Old
/en/paths; - Default language
home_url(); - Old page associations in navigation.
2. Dynamic Links and Hardcoded Links Need to Be Handled Separately
Dynamic links are suitable for repair via small-scale code patches.
Hardcoded links should be modified directly in their corresponding templates or navigation blocks.
3. Different Templates in a Block Theme Are Independent of Each Other
The Blog Homepage template, All Archives template, Header template component, and Footer template component might each store their own block content.
Modifying an About link in one template does not mean that similar links in other templates will automatically update.
4. After Updating WPCode, Pay Attention to the Object Cache
In the current W3 Total Cache multi-domain environment, a successful WPCode save does not mean that other Hosts will immediately read the latest code snippet.
If you encounter:
www domain loaded
en domain not loaded
You should prioritize checking the current Host’s Object Cache, rather than continuing to modify the code.
5. Do Not Rely Solely on Whether the Page Loads
Old links might continue to work via 301 redirects, but they still introduce:
- Extra redirects;
- Incorrect language switching;
- Increased cache complexity;
- Inconsistent search engine crawl paths;
- Difficulties in subsequent rule maintenance.
The final inspection should simultaneously focus on:
- The raw
href; - HTTP status codes;
- The final URL;
- Number of redirects;
- Page language;
- canonical;
- Actual browser interactions.
21. Summary
This issue initially appeared as just a 404 returned by the English category dropdown list, but a complete inspection revealed that it involved multiple different layers:
Polylang language domains
WordPress block dynamic scripts
Block theme templates
Language Visibility
Navigation hardcoded links
Breadcrumb homepage links
WPCode
W3 Total Cache Object Cache
Cloudflare page cache
The final approach adopted was:
- Fixing the category dropdown list with a frontend event patch;
- Fixing the site title and breadcrumb Home using the current domain;
- Changing Home and Blog in the English menu to
/; - Changing the English About link to a relative path;
- Inspecting the Blog Homepage and All Archives templates separately;
- Flushing the W3 Total Cache Object Cache by Host;
- Letting the old Cloudflare cache expire naturally.
Ultimately, the English homepage and English category archive pages no longer contain incorrect Chinese domains or old /en/ links. The category dropdown, pagination, breadcrumbs, and navigation have all returned to normal.

