【问题标题】:Wordpress | Yoast SEO - Change slug or fragment in XML sitemapWordPress | Yoast SEO - 更改 XML 站点地图中的 slug 或片段
【发布时间】:2016-08-16 02:32:21
【问题描述】:

问题 Yoast SEO 生成带有导致 404 错误的链接的 XML 站点地图。

因为 我在我的functions.php 中使用WPML 和一些str_replace 脚本来重写slugs/permalinks。 Yoast SEO 的 XML 站点地图生成器没有在我的 functions.php 中使用这些脚本,因此它会生成无效链接。

我的 str_replace 脚本正在更改自定义帖子类型 slug:

英语 domain.com/news/taxo_en1/taxo_en2/title

荷兰语 domain.com/nl/nieuws/taxo_nl1/taxo_nl2/titel

XML 站点地图显示了这一点 荷兰语 domain.com/nl/news/taxo_nl1/taxo_nl2/titel

有没有办法更改 XML 站点地图中生成的链接?使用 wpseo_do_sitemap 挂钩还是?

【问题讨论】:

    标签: wordpress seo


    【解决方案1】:

    也许这对其他人有帮助,我找到了这个过滤器:

    function filter_wpseo_sitemap_entry( $url, $term, $term ) {
    
    return str_replace("要搜索的字符串", "要替换的字符串", $url);
    
    }
    
    add_filter('wpseo_sitemap_entry', 'filter_wpseo_sitemap_entry', 10, 2);
    

    更新/保存帖子时会生成新链接

    最好的问候 迈克

    【讨论】:

      猜你喜欢
      • 2021-09-18
      • 2017-11-15
      • 1970-01-01
      • 1970-01-01
      • 2019-08-18
      • 2014-10-05
      • 1970-01-01
      • 2022-10-19
      • 1970-01-01
      相关资源
      最近更新 更多