Hi,
Remove
add_action( 'template_redirect', 'remove_author_pages_page' );.
It’s exists another line in function.php.
Didn’t you copy and paste this code together?
Thanks for your reply. I did copy and paste the code and the extra add_action was there. I just omitted it when posting here for some reason.
In any case your solution did the trick. It now redirects to 404 without the warnings.
Thanks again for your support.
One more question if you don’t mind?
I would like to now have it redirect to the home page instead of 404 page.
The example states that I just have to comment out the two lines for the 404 redirect and uncomment the wp_redirect which I did.
It still redirects to a 404 page and I was wondering if there is another way to achieve what I want?
Thanks again for your support.
function my_custom_disable_author_page() {
global $wp_query;
if ( is_author() ) {
// $wp_query->set_404();
// status_header(404);
// Redirect to homepage
wp_redirect(get_option('home'));
}
}
add_action('template_redirect', 'my_custom_disable_author_page');
@nootkan
You must exit after wp_redirect.
wp_redirect(get_option('home'));
exit();
-
This reply was modified 6 years, 2 months ago by
munyagu.
Once again thank you for replying it is greatly appreciated.
I did try using exit; as per this link: function wp_redirect
Even with the parenthesis added as per your solution, it still isn’t working.
It seems no matter what I try I get sent to a 404 page every time.
I’ve cleared cache, tried several browsers to confirm it wasn’t a cache issue and tried various code changes based on google searching.
I’ve de-activated/re-activated all plugins one at a time and used ctrl F5 to clear cache but that didn’t show any conflicts with plugins. Did the same for the theme.
One thing I noticed is when I remove the snippet entirely from the child theme>>fuctions.php file the 404 issue still exists.
So now I assume there must be another issue and the snippet works.
I will keep trying but I may have to settle for the 404 error page (hopefully not).
Any other ideas that may lead me to a solution?
Thanks again for your support!
-
This reply was modified 6 years, 2 months ago by
nootkan. Reason: added more content