Opened 5 years ago
Closed 5 years ago
#50644 closed defect (bug) (duplicate)
Changing Search Engine Visibility option does not immediately (de)activate sitemaps
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.5 |
Component: | Sitemaps | Keywords: | |
Focuses: | Cc: |
Description
The "Discourage search engines from indexing this site" option in Settings -> Reading can be used to add noindex directives to the robots.txt file. At the same time, it also disables XML sitemaps, and prevents the feature from initializing in the first place.
That means if you have the option currently checked, and uncheck it, the sitemaps won't work until after you've flushed the rewrite rules.
Ideally, when the option is toggled we should flush the rewrite rules accordingly.
However, the option value can also be filtered programmatically using pre_option
filters. Just like the wp_sitemaps_enabled
filter can be used.
So maybe an alternative solution could be to always register the rewrite rules, even if the feature is disabled, but then handling the response codes (404 vs 200) accordingly.
Related: #50643
The preliminary patch at #50643 might solve this one too.