Skip to content

mindkomm/theme-lib-404

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

404

404 status helper function for WordPress themes.

Installation

You can install the package via Composer:

composer require mindkomm/theme-lib-404

Functions

Name Summary Type Returns/Description
force_404 Forces 404 headers on a query.

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.

About

404 status helper function for WordPress themes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages