如何触发404模板显示?我做了以下......
$_escaped_fragment_ = $_REQUEST['_escaped_fragment_'];
$post = ( get_page_by_path($_escaped_fragment_,'','brands' ) );
if(!empty($post) ){
setup_postdata($post);
the_title();
get_template_part('loop');
wp_reset_postdata();
}else{
get_404_template();//not working
include( get_query_template( '404' ) );//not working...
}
答案 0 :(得分:4)
这个怎么样?这应该有效。
status_header(404);
include( get_404_template() );
exit;
而不是
get_404_template();//not working
include( get_query_template( '404' ) );//not working...