I am trying to add custom html to a 404 page in wordpress.
<?php
$filename = "/find";
if (!file_exists($filename))
echo $filename, " display html2 ";
elseif (!is_dir($filename))
echo $filename, " display html1 ";
?>
If someone visits http://www.demosite.com/about/whatever = Display HTML 1
If someone visits http://www.demosite.com/find/whatever = Display HTML 2
Is this even possible with PHP and HTML?
<?php
$filename = "/find";
if (is_dir($filename)){
echo $filename, " display html1 ";
include('html1.html');
}
else{
echo $filename, " display html2 ";
include('html1.html');
}
?>
This code checks for the folder "find" if it exists it shows html1 else html2.
I guess the better option for you will be this :
Use htaccess when user browse http://yourdomain/about/whatever
show the contents from http://yourdomain/page.php?p=about&var=whatever
And get the value of p in your page using $_GET['p']
, and show the html accordingly
if($_GET['p'] == "find"){
include('html1.html');
}else{
include('html2.html');
}