Blank 404 error page
-
I am trying to get my custom 404 error page twig template to display on 404 errors. Currently, my 404 errors are showing a blank screen. However, when I go to the route: /404 my template displays. I am assuming there is either something wrong with how I am routing or I am missing some key logic in 404.php.
How can I get my twig template to display for my 404 errors?
Route code in functions.php:
Routes::map('/404', function($params){ Routes::load('routes/404.php', null, $params, 404); });
404.php:
<?php $context = Timber::get_context(); $post = new TimberPost(); $context['page'] = $post; global $wp; $url = home_url($wp->request); $context['url'] = preg_replace('#^https?://#', '', rtrim($url, '/')); $context['global'] = get_fields('options'); Timber::render('views/pages/404.twig', $context);
404.twig:
{% extends "layouts/layout.twig" %} {% block content %} <div class="row row-is-centered"> <div class="col ns-col-is-8 lead-6 txt-center"> <h1 class="txt-size-5">Our apologies, we couldn't find {{url}}</h1> </div> </div> {% endblock %}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Blank 404 error page’ is closed to new replies.