Skip to content

Instantly share code, notes, and snippets.

@tatthien tatthien/functions.php

Last active Oct 1, 2019
What would you like to do?
Redirect pages to 404 with a conditional in WordPress
function redirect() {
if(true === $something) {
/* @var WP_Query $wp_query */ global $wp_query;
status_header( 404 );
get_template_part( '404' );
add_action( 'template_redirect', 'redirect' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.