0

i build a template for a 404 Error page.

I would like to manage the template via the wordpress backend under "pages". Unfortunately, this does not work or changes that I want to make with custom fields are not displayed. Is there a possibility here?

i use the following code:

<header id="page-header" style="background-image: url(<?php the_field('404_background'); ?>)">
        <div class="container">

            <div class="title-wrapper">             
                     <p>
                        <?php if (get_field('sub_title')):
                            the_field('sub_title');
                        endif; ?>                       
                    </p>
                    <h1>
                        <?php if (get_field('title_h1_uberschrift')):
                            the_field('title_h1_uberschrift');
                        endif; ?>
                    </h1>                       
                </div>

But the custom fields are not shown in the frontend. For all other sites it works fine....

  • WP uses your theme's 404.php. Create a child theme, copy 404.php, then have it pull the page you've created by ID along with its custom fields. Also keep in mind some people may accidentally visit that page since it's actually a valid page, not just a 404 error, so you'll want to make sure it's excluded from sitemaps and links. – WebElaine Jul 9 '18 at 15:04
  • yes, I have created a 404.php, created a page and assigned this template. But the custom fields remain empty – tom84 Jul 9 '18 at 15:23
  • Do you mean the custom fields are showing on the back end (editing screen) but not on the front end? Can you share the code you're using in the template to pull and display the custom fields? – WebElaine Jul 9 '18 at 15:25
  • yes... the content of the custom fields is not shown in the frontend! It is shown on the site www.homepage/error-404-page. but it is not shown as a 404 site if i call www.homepage/xyz – tom84 Jul 9 '18 at 18:57
  • 1
    associating the 404 template with a page does not make the 404 template always render that page. when you have a true 404 error, you will need to manually query that page's content and output it in the template yourself. – Milo Jul 9 '18 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.