Skip to content

Instantly share code, notes, and snippets.

@cagrimmett
Last active November 26, 2019 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cagrimmett/38d146ead03b5c34a3ea876d94fe0f4e to your computer and use it in GitHub Desktop.
Save cagrimmett/38d146ead03b5c34a3ea876d94fe0f4e to your computer and use it in GitHub Desktop.
redirect blog.crash.co posts to crash.co
<?php
add_action( 'template_redirect', function() {
global $post;
if ( current_user_can('administrator') ) { return; }
if (is_single()){
$cat = get_the_category();
wp_redirect( 'https://crash.co/content/' . $cat[0]->slug . '/' . $post->post_name );
die;
} else {
wp_redirect( 'https://crash.co/content/all' );
die;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment