LoginSignup
2
1

More than 5 years have passed since last update.

WordPress外のPHPスクリプトで、WordPressの404ページを使う

Posted at

概要

WordPressで運用しているサイトに、何らかの理由で別のPHPスクリプトを導入している。そのスクリプトで 404 が発生した時、WordPress で管理している404ページを出力する。

方法

wp-load.php を読み込み、404ページを読み込む。
404ページのパスは get_404_template 関数で取得できる。

実装

require_once('wp-load.php');

http_response_code(404);
include(get_404_template());
exit;
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1