Archived topic
Insert Image into Custom 404
13 replies · Started by Zad on November 7, 2018
I currently have this PHP function to generate a custom 404 page. I was wondering if there was anyway to include an image into the custom 404 page, and if so, how would I incude it into the php function code below?
add_filter( 'generate_404_title','generate_custom_404_title' );
function generate_custom_404_title()
{
return 'Ruh roh!';
}
add_filter( 'generate_404_text','generate_custom_404_text' );
function generate_custom_404_text()
{
return 'Looks like ya done goofed! Try searching again.';
}
Hi there,
You should be able to use Hooks Element:
https://docs.generatepress.com/article/hooks-element-overview/
https://docs.generatepress.com/article/hooks-visual-guide/
Select 404 Template under Display Rule.
Let me know if this helps :)
Hi I created a hook and copy and pasted the above PHP code but I'm not sure what short code to insert to actually load the image into the CUstom 404 page. I plan on uploading the image as a normal image but as an SVG file
Okay I got it, I have a separate PHP function with the code above and a separate hook inserting the image using DIV, but I'm trying to center the image and make it come before the search button. Any way to do that?
No php code should be needed to insert the image.
Simply create a hook element, add the image using HTML then set select 404 template in display rule.
As for centering, can you link me to a 404 page?
Thanks!
Yes, here's one
Since you already gave the image a div, this CSS should work:
.Custom404, .error404 .search-form {
text-align: center;
}
Almost looks good! Here's where it's currently at. Any way to center the search bar?
https://imgur.com/a/N1Gsp7i
Edited the CSS above to include the search form:
https://generatepress.com/forums/topic/insert-image-into-custom-404/#post-722583
Yes, it looks good. THanks a bunch!!!!!
Sorry, last question. Any way I can reduce the padding below the image?
Try this:
.error404 .entry-content {
margin-top: 0.25em;
}
It worked guys! Thanks so much!
Glad we could help