Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Created February 9, 2012 18:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisguitarguy/1781733 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/1781733 to your computer and use it in GitHub Desktop.
rewrite help for WPSE
<?php
/*
Plugin Name: WPSE 41778 Rewrite
Author: Christopher Davis
Author URI: http://christopherdavis.me/
*/
add_action( 'init', 'wpse41778_add_rewrite' );
function wpse41778_add_rewrite()
{
add_rewrite_tag('%gallery%','([^/]+)');
add_rewrite_tag('%album%','([^/]+)');
add_rewrite_rule(
'^galleries/([^/]+)/?$',
'index.php?pagename=galleries&album=1&gallery=$matches[1]',
'top'
);
}
register_activation_hook( __FILE__, 'wpse41778_flush_rewrite' );
function wpse41778_flush_rewrite()
{
wpse41778_add_rewrite();
flush_rewrite_rules();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment