Hi Carl,
you have “All 404 Redirect to Homepage” plugin that redirecting it to homepage.
please use following code snippet.
add_action('wp', 'gd_patch_p404_redirect', 1);
function gd_patch_p404_redirect(){
remove_action( 'wp', 'p404_redirect' );
if ( is_404() && !is_search() && empty( $_REQUEST['geodir_search'] ) )
{
$options= P404REDIRECT_get_my_options();
$link=P404REDIRECT_get_current_URL();
if($link == $options['p404_redirect_to'])
{
echo "<b>All 404 Redirect to Homepage</b> has detected that the target URL is invalid, this will cause an infinite loop redirection, please go to the plugin settings and correct the traget link! ";
exit();
}
if($options['p404_status']=='1' & $options['p404_redirect_to']!=''){
$links = P404REDIRECT_read_option_value('links',0);
P404REDIRECT_save_option_value('links', $links + 1);
P404REDIRECT_add_redirected_link(P404REDIRECT_get_current_URL());
header ('HTTP/1.1 301 Moved Permanently');
header ("Location: " . $options['p404_redirect_to']);
exit();
}
}
}
Thanks