Skip to content

Instantly share code, notes, and snippets.

@micahwave
Created July 2, 2012 19:20
Show Gist options
  • Select an option

  • Save micahwave/3035095 to your computer and use it in GitHub Desktop.

Select an option

Save micahwave/3035095 to your computer and use it in GitHub Desktop.
rewrite rules
// make it so we can use /photo/x/ with galleries
function time_rewrite_rules() {
global $wp_rewrite;
add_rewrite_tag( '%photo%', '([^&]+)' );
add_rewrite_tag( '%slide%', '([^&]+)' );
add_rewrite_tag( '%tab%', '([^&]+)' );
add_rewrite_endpoint('photo', EP_PERMALINK);
add_rewrite_endpoint('video', EP_PERMALINK);
add_rewrite_endpoint('slide', EP_PERMALINK);
add_rewrite_rule( '^contributors/(.+?)/page/([0-9]{1,})/?$', 'index.php?pagename=contributors&tab=$matches[1]&paged=$matches[2]', top );
add_rewrite_rule( '^contributors/([^/]*)/?', 'index.php?pagename=contributors&tab=$matches[1]', top );
$wp_rewrite->flush_rules();
}
add_action('init', 'time_rewrite_rules', 999);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment