Created
May 1, 2021 01:00
-
-
Save cameronjonesweb/9114814ee0b52c865de3f97d499295ed to your computer and use it in GitHub Desktop.
Fix 404 pages returning true for have_posts if permalinks have a prefix ie "/news/%postname/"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function cameronjonesweb_404_fix() { | |
global $wp_query; | |
if ( $wp_query->is_404 ) { | |
$wp_query->posts = array(); | |
$wp_query->current_post = 0; | |
$wp_query->post = null; | |
} | |
} | |
add_action( 'template_redirect', 'cameronjonesweb_404_fix' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment