How to Redirect Author Pages in WordPress

There are a few reasons why you might want to redirect author pages on a website:

  • If a website has multiple authors, each with their own author page, redirecting all of these pages to a single page can help consolidate the content and make it easier for users to find information about all of the authors in one place.
  • Maintaining multiple author pages can be time-consuming, especially if the website has a large number of authors. Redirecting these pages can help reduce the amount of maintenance required.

Code Snippets

This code defines a function called redirect_author_archive which redirects the user to the about page of the website if they are not an administrator.

function redirect_author_archive() {
  if(!is_admin()) {
    wp_redirect(home_url('about'));
    exit();
  }
}
add_action('template_redirect', 'redirect_author_archive');

This code defines a function called redirect_author_archive which redirects the user to the homepage of the website if they are not an administrator.

function redirect_author_archive() {
  if(!is_admin()) {
    wp_redirect(home_url('/'));
    exit();
  }
}
add_action('template_redirect', 'redirect_author_archive');

More Code Snippets

There are more code snippets where this came from.

  1. Add Reusable Blocks to Admin Menu
  2. How to Stop WordPress From Guessing URLs
  3. How to Apply CSS Conditionally
  4. GeneratePress Hooks: Simple Guide
  5. Adding a Class to Images, Videos, and Iframes
  6. How To Remove the Category From the WordPress URL
  7. How to Delay The Execution of JavaScript without a plugin
Manuel Campos, English Professor

Manuel Campos

I am José Manuel. I am writing about things I know and things that I am learning about WordPress. I hope you find the content of this blog useful.

WP SURFER

home

about

privacy

contact

© 2024 WP SURFER • Made with Love in Costa Rica