对于我的生活,我无法弄清楚为什么 wordpress 不会运行这个过滤器。我将它添加到我的 Active Child 主题的 functions.php 中,functions.php 中没有其他代码
/* Add External Sitemap to Yoast Sitemap Index
* Credit: Paul https://wordpress.org/support/users/paulmighty/
* Last Tested: Oct 07 2016 using Yoast SEO 3.6 on WordPress 4.6.1
*/
add_filter( 'wpseo_sitemap_index', 'add_sitemap_custom_items' );
function add_sitemap_custom_items(){
$sitemap_custom_items = '<sitemap>
<loc>http://www.website.com/external-sitemap.xml</loc>
<lastmod>2017-05-22T23:12:27+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.website.com/external-sitemap-2.xml</loc>
<lastmod>2017-05-22T23:12:27+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.website.com/external-sitemap-3.xml</loc>
<lastmod>2017-05-22T23:12:27+00:00</lastmod>
</sitemap>';
return $sitemap_custom_items;
}
这是从这里复制的:https ://kb.yoast.com/kb/add-external-sitemap-to-index/
这没用。我正在使用 Yoast 5.0 和 Wordpress 4.8