Created
September 15, 2016 07:05
-
-
Save saxap/a867f4823838aac32eda4bf55fb4e920 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
add_action( 'template_redirect', 'so16179138_template_redirect', 0 ); | |
function so16179138_template_redirect() | |
{ | |
if( is_singular() ) | |
{ | |
global $post, $page; | |
$num_pages = substr_count( $post->post_content, '<!--nextpage-->' ) + 1; | |
if( $page > $num_pages ){ | |
include( get_template_directory() . '/404.php' ); | |
exit; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment