Site logo

Archived topic

Insert Image into Custom 404

13 replies · Started by Zad on November 7, 2018

Viewing posts 1–14 of 14

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 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?

https://imgur.com/a/TYhze6Z

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!

Since you already gave the image a div, this CSS should work:

.Custom404, .error404 .search-form {
    text-align: center;
}

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

This archived topic is closed to new replies.