So I’m going to post what I managed to figure out for anyone else that needs help with this issue.
First off, I did manage to find the pages that Menaka posted via the Internet Archive’s WayBack Machine. Links below:
How to Customize the 404 page
Modify Layout 404 and Search
Customizing the 404 page
Using these pages plus some other resources I managed to build some snippets that seem to be working! I’m going to post them below so that others might have something to work with if they need to make similar changes. ??
Code to alter 404 Page Contents
Make sure to put your custom classes, text, and the full url path to your image for it to work.
//Code to alter 404 Page
add_filter('tc_404_content', 'my_404_content');
function my_404_content(){
$text_404 = '<p class="your-custom-class">Your custom text</p>';
$image_url = 'https://www.yourwebsite.com/path/to/your/image.png';
return sprintf('<img alt="Not Found" class="your-custom-class" src="%1s">%2$s',
$image_url,
$text_404
);
}
Code to alter No Result Page Contents
Make sure to put your custom classes, text, and the full url path to your image for it to work.
//Code to alter No Result Page
add_filter('tc_no_result_content', 'my_no_result_content');
function my_no_result_content(){
$text_noresult = '<p class="your-custom-class">Your custom text</p>';
$image_url = 'https://www.yourwebsite.com/path/to/your/image.png';
return sprintf('<img alt="No Results Found" class="your-custom-class" src="%1s">%2$s',
$image_url,
$text_noresult
);
}
Code to alter Search Results Page
This code basically just removes the search box from the Search Results page. Our search is always visible and we didn’t need the search results page to display another one.
// Removes search box from search results page
add_filter('tc_search_results_header_content','my_results_header');
function my_results_header($content) {
return substr($content,0,strpos ($content,"<form",0));
}
I hope this helps! I’m still working on getting a handle on WordPress hooks, functions, and PHP in general. I would suggest anyone that tries the above code, do so first on a test site.
In fact anytime you mess with the functions.php, you should probably test it on a development site first. PHP isn’t very forgiving and if you screw up, you’ll probably get the white screen of death. That can be fixed by using an FTP or if you host provides it the CPanel, removing whatever messed up code is in the functions.php and re-saving it. On a local test site or development server you can experiment, make mistakes, and not worry about a live site going down.