/* 404 redirect is Coupons or Deals
----------------------------------------------------------------- */
add_action( 'wp', 'rr_404_my_event' );
function rr_404_my_event() {
if ( is_single() ) {
$arr_cat = get_the_category(get_the_ID())[0];
if($arr_cat->term_id==3 || $arr_cat->term_id==4){
global $wp_query;
$wp_query->set_404();
status_header(404);
}
}
}
当 post 在 cat 3或 4 里时 跳转到 404 页面。
wordpress 添加404 跳转事件 hook
最新推荐文章于 2023-08-12 12:47:50 发布