你可以404.php 文件这是作为主题的一部分的普通文件。您可以在其中处理所有逻辑,并让它加载动态html。
OR
您可以在函数中使用如下函数。php文件。我刚刚测试过,您可以使用
var_dump()
放置在此函数中。
// borrowed from http://wordpress.stackexchange.com/a/1883/10907
function stoi2m1_404_override() {
global $wp_query;
// return if not a 404 page
if (!$wp_query->is_404)
return;
// dump the data in the query, parameters from the URL
echo \'<pre>\';
var_dump($wp_query->query);
echo \'</pre>\';
/* resulted in something like this for me, Im using a custom post type movies
array(4) {
["page"]=>
string(0) ""
["movies"]=>
string(4) "missing"
["post_type"]=>
string(6) "movies"
["name"]=>
string(4) "missing"
}*/
if ($wp_query->query[\'name\'] == \'missing\' ) { //what ever name/title of post you are looking for
status_header( 200 ); // set the appropriate header
$wp_query->is_404=false; // set is_404 to false
// apply any more logic you need here
// or include custom template file here
// you will want to keep the usual template from loading
}
}
add_filter(\'template_redirect\', \'stoi2m1_404_override\' );