我的网站在用户发布二手车详细信息后自动生成的自定义URL。如何在yoast sitemap.xml中包含这些URL。
url生成:https://www.carsangrah.com/used_car/tamil nadu/chennai/maruti-suzuki-suzuki-s-cross-ddis-ddis-200 zeta_8444444444444444444444444444444444444444444444444
生成的SiteMap:https://www.carsangrah.com/sitemap_index.xml
此SiteMap不包括以上生成的URL。请建议我正确的方式包含这些URL。
有点晚了,但是您可以使用'wpseo_sitemap_index'(http://hookr.io/filters/wpseo_sitemap_index/)将附加文本添加到yoast SiteMap中。
示例:
<?php
function _add_custom_items(){
$appended_text = '';
$post_id = 1; //Use whatever method to get your post info
$your_post = get_post($post_id);
$your_post_link = get_permalink($post_id);
$appended_text .= '<sitemap>' .
'<loc>' . $your_post_link . '</loc>' .
'<lastmod>' . str_replace(' ', 'T', $your_post->post_modified) . '+00:00</lastmod>' .
'</sitemap>';
}
return $appended_text;
}
add_filter( 'wpseo_sitemap_index', '_add_custom_items' );
?>
使用yoast插件,我认为您无法在站点地图中添加自定义URL。
但是您可以使用Google XML Sitemaps插件,该插件将允许您在站点地图中添加自定义链接。
这是如何在SiteMap中添加自定义URL的详细说明。