mindkomm/theme-lib-404

404 status helper functions for WordPress themes

Installs: 531

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 0

Open Issues: 0

pkg:composer/mindkomm/theme-lib-404

1.0.0 2018-02-13 09:29 UTC

This package is auto-updated.

Last update: 2025-10-05 07:15:28 UTC


README

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.