I have a WordPress plugin that has the following code inside header.php:
<?php
if (the_subtitle("","", false) == "") {
the_title();
} elseif(is_404()) {
echo "404";
} else {
the_subtitle();
}
?>
Basically, this should happen:
But for some reason, when I locate my 404.php page, there is nothing displayed. Why?
If your first check is for subtitle
and your 404
-page has no subtitle
then that part of the if-statement
is triggered and all other checks are skipped. By performing the 404
check first things should work as expected.
<?php
if (is_404()) {
echo "404";
} elseif (the_subtitle("","", false) == "") {
the_title();
} else {
the_subtitle();
}
?>