Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Documentation: The "Exclude a taxonomy term from sitemap" code doesn't do anything

未关闭
#340 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
wordpress
领域
documentation

调研方向

从 docs/features/xml-sitemaps/api.md 开始,根据报告的行为检查文档中 wpseo_exclude_from_sitemap_by_term_ids 的示例。调查 issue 中提到的相关过滤器,包括 wpseo_sitemap_entry,然后更新或删除相关说明,确保文档中排除 taxonomy term 的方式准确且可测试。

由索引模型根据 Issue 内容生成。

描述

Please give us a description of the issue

On https://github.com/Yoast/developer/blob/main/docs/features/xml-sitemaps/api.md you give a function for removing taxonomy terms from site maps.

I've aadded the following code to my theme functions.php:


function sitemap_exclude_terms( $terms ) {
return [208];
}

add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', 'sitemap_exclude_terms' );

Posts in category ID 208 are still appearing on my post-sitemap.xml. I know it's not a caching issue because I subsequently added a test post and it appeared in the sitemap immediately. I have tested this with numerous different categories and with including single or multiple IDs in the array.

The code should probably either be corrected or removed.

  • [X ] I've read and understood the contribution guidelines.
  • [X ] I've searched for any related issues and avoided creating a duplicate issue.

UPDATE: The only way I was able to actually successfully filter the sitemap was using the wpseo_sitemap_entry filter. Filters I tried that didn't seem to ever run: wpseo_exclude_from_sitemap_by_term_ids, wpseo_sitemap_exclude_post, and a query with wpseo_sitemap_posts_query. Some sort of clearer documentation might have saved me some time.

主要语言
JavaScript
星标
15
派生
23
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Yoast/developer 的其他 Issue

查看 Yoast/developer 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。