Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress: Can 404.php page send values to header.php?

Tags:

wordpress

Is it possible to place code in the 404.php file which will change elements in the header.php file?

For example, if a 404.php page is loaded, I want the page's title and description to be filled in with specific values.

However, as it is these values are empty.

like image 300
Scott B Avatar asked Apr 27 '26 14:04

Scott B


1 Answers

Yes, like objects said:

An example of your header.php:

<html>
<head>
    <title><?php if(is_home()) { echo "Home"; } elseif(is_404()) { echo "Error!"; } elseif(is_page()) { echo "Page"; } elseif(is_single()) { echo "single"; } else { "Anything else"; } ?></title>
</head>
<body>

WordPress Hooks are very easy to use

like image 95
ahmet2106 Avatar answered May 02 '26 03:05

ahmet2106



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!