I have a WordPress app that displays a title depending on the page:
<?php
if (is_404()) {
echo "404. Page not found.";
} elseif (is_page('46')) {
echo "NOT WORKING";
} elseif (the_subtitle("","", false) == "") {
the_title();
} else {
the_subtitle();
}
?>
Basically, on the specific page (page 46, which I’ve confirmed by printing out the page id), I want to display a specific title. But for some reason when I visit page 46, I get the title of the page instead, instead of “NOT WORKING”?
If this code is in your functions.php file, you would need an action or filter to make it run at the appropriate time. Here’s an example of what you might add to the functions.php file to achieve the result you’re looking for: