Skip to content

Instantly share code, notes, and snippets.

@camaleaun
Created July 25, 2018 18:35
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 camaleaun/6b27ada6afc53213013780cfab6860d2 to your computer and use it in GitHub Desktop.
Save camaleaun/6b27ada6afc53213013780cfab6860d2 to your computer and use it in GitHub Desktop.
add_action( 'init', 'short_aliases' );
add_filter( 'short_aliases', 'shorts_redirect' ) );
function short_aliases() {
$aliases = apply_filters( 'short_aliases', array() );
if ( ! is_array( $aliases ) ) {
$aliases = array();
}
foreach ( $aliases as $alias => $redirects ) {
add_rewrite_rule( "^$alias/?", $redirects, 'top' );
}
}
function shots_redirect( $redirects ) {
$short = get_query_var( 'short' );
$redirects['slug'] = get_post_type_archive_link( 'page' );
return $redirects;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment