mindkomm / theme-lib-404
404 status helper functions for WordPress themes
1.0.0
2018-02-13 09:29 UTC
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2024-11-05 05:00:54 UTC
README
404 status helper function for WordPress themes.
Installation
You can install the package via Composer:
composer require mindkomm/theme-lib-404
Functions
force_404
Forces 404 headers on a query.
Use this function in a WordPress template file.
When a template other than 404.php is loaded, the proper headers for a 404 status are not set properly. This function can be used to set proper headers even after a template file is loaded.
What you have to do after this request is to include the 404 template and exit after it.
PHP
if ( 'publish' !== $post->post_status ) { force_404(); Timber::render( '404.twig', $context ); exit; }
Support
This is a library that we use at MIND to develop WordPress themes. You’re free to use it, but currently, we don’t provide any support.