Created
February 9, 2012 18:15
-
-
Save chrisguitarguy/1781733 to your computer and use it in GitHub Desktop.
rewrite help for WPSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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