Damian Cardona
Damian Cardona

Reputation: 326

While having WordPress site, how do I make a custom php web page viewable outside the WordPress environment?

I have a WordPress site where a client wanted to add a custom web page (ex. custompage.php) so that they go to example.com/custompage. This custom page is just HTML and not related to WordPress, but simply making that page with that address goes to a 404 error in WordPress. How do I allow custom web pages to be viewed before having a WordPress check, so to speak?

Upvotes: 0

Views: 54

Answers (1)

gael
gael

Reputation: 1493

First you could add WP template tags on top of your PHP file so that WordPress will understand its a page template.

The file custompage.php must be inside your Custom/Child theme directory.

<?php
/**
 * Template Name: custompage
 *
 */?>
<html><head></head><body>
<p>Your html...<p>

Then in WordPress dashboard, create a new page with the title custompage to make sure the slug is generated as wanted but it can be edited.

For this new page, in page attributes, select the newly created page template custompage and publish it.

You will be able to access example.com/custompage with your beautifull html displaying.

Upvotes: 2

Related Questions