Chhorn Soro
Chhorn Soro

Reputation: 3151

Add Static php file but still can use wordpress template

I just want to create one static PHP file in the theme folder, but I can't use get_header or anything.

How can I access to the WordPress API with static PHP file?

Upvotes: 0

Views: 134

Answers (1)

Alexander O'Mara
Alexander O'Mara

Reputation: 60537

You would have to load the wp-load.php file to bootstrap WordPress. This can be done with the following code.

require __DIR__ . '/../../../wp-load.php';

Fair warning, this is not the ideal way to do things like this. You would most-likely be better off using the template_redirect action hook to output different content.

Upvotes: 1

Related Questions