Skip to content

Instantly share code, notes, and snippets.

@runezero
Last active November 8, 2022 21:18
Show Gist options
  • Select an option

  • Save runezero/a6e1d6a93442a871d5b7c7750f7a6c3b to your computer and use it in GitHub Desktop.

Select an option

Save runezero/a6e1d6a93442a871d5b7c7750f7a6c3b to your computer and use it in GitHub Desktop.
[Redirect from category] If on category page, redirect to the home page #wordpress
<?php
/* Register template redirect action callback 24-05-2019 */
add_action('template_redirect', 'code_remove_wp_archives');
/* Remove archives */
function code_remove_wp_archives(){
//If we are on category or tag (data and autheur is done via YoastSEO)
if( is_category() || is_tag() ) {
wp_redirect( home_url());
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment