首页 > 解决方案 > 如何使用 Yoast SEO 在站点地图中包含具有自定义帖子状态的帖子?

问题描述

archived我使用该功能创建了一个自定义帖子状态register_post_status。我刚刚意识到插件 Yoast SEO,不会在站点地图中使用它。只有那些在发布中。

如何在站点地图中包含自定义帖子状态?

标签: wordpressyoast

解决方案


Yoast SEO在 11.2 版本中实现了一个新的过滤器来处理这个问题

这是执行此操作的方法:

function yoast_add_custom_status( $post_statuses) {
    // var_dump($post_statuses);die();
    $post_statuses = array( 'publish','YOUR_CUSTOM_STATUS' ); //add your custom statuses
  return $post_statuses;
}
add_filter( 'wpseo_sitemap_post_statuses', 'yoast_add_custom_status');

推荐阅读