admin管理员组文章数量:1205744
I'd like to return a 410 code for posts (of custom type "news") which have previously been published (and therefore have a url indexed by search engines), but have now had the post status set to draft.
Here's my attempt:
function news_gone() {
global $post;
if ( is_singular( 'news' ) && get_post_status($post->id) == "draft" ) {
global $wp_query;
$wp_query->set_404();
status_header(410);
}
}
add_action( 'template_redirect', 'news_gone' );
This, however, has no effect - is template_redirect
the correct hook, or is there a better approach?
本文标签: redirectHow to return a 410 code for previously published posts now set to draft
版权声明:本文标题:redirect - How to return a 410 code for previously published posts now set to draft? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738707958a2108024.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论