Disable and redirect pagination of Home
My home is a static page, but Wordpress create enumeration home/page/2/.../3/ and the only solution found that disable pages generation, also redirecting, is the instruction below, but I would like it to have effect only the home page and not the whole site.
Thank you in advance for any suggestions.
global $posts, $numpages;
$request_uri = $_SERVER['REQUEST_URI'];
$result = preg_match('%\/(\d)+(\/)?$%', $request_uri, $matches);
$ordinal = $result ? intval($matches[1]) : FALSE;
if(is_numeric($ordinal)) {
setup_postdata($posts[0]);
$redirect_to = ($ordinal 2) ? '/': (($ordinal $numpages) ? /$numpages/ : FALSE);
if(is_string($redirect_to)) {
$redirect_url = get_option('home') . preg_replace('%'.$matches[0].'%', $redirect_to, $request_uri);
if($ordinal 2) {
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
} else {
header($_SERVER['SERVER_PROTOCOL'] . ' 302 Found');
}
header(Location: $redirect_url);
exit();
}
}
Topic homepage pagination Wordpress
Category Web