When I go to the url mysite.com/photos/120 I'm wanting to get the 120 out.
In the PHP I want to be able to grab these "parameters" like the url was mysite.com?page=photos&id=120 or even just mysite.com/photos?id=120
Can I leverage rewrite rules? Or do I need to do regex in php to get what I want?
Thanks
** EDIT 1 **
For the life of me I can't get this to work. Based on the answers given (thanks) here is what I have:
add_action( 'init', 'rewrite_photo_url' );
function rewrite_photo_url() {
add_rewrite_rule( '^photos/([^/]*)/?','index.php?page=photos&photo_id=$matches[1]', 'top' );
}
add_rewrite_tag('%id%','([0-9]+)');
print(get_query_var('photo_id'));
I suspect I'm missing a concept somewhere?
** EDIT 2 **
I'm starting to see that perhaps this needs to be in functions.php so I now have:
function rewrite_photo_url() {
add_rewrite_rule( '^photos/([^/]*)/?','index.php?page=photos&photo_id=$matches[1]', 'top' );
}
function register_custom_query_vars( $vars ) {
array_push( $vars, 'photo_id' );
return $vars;
}
add_action( 'init', 'rewrite_photo_url');
add_filter( 'query_vars', 'register_custom_query_vars', 1 );
Now I just need to know how to get my desired var in my page template. I've tried
print(get_query_var('photo_id'));
But that's not doing the trick atm.

photo_idas your variable in the rewrite rule, but addidinstead ofphoto_idwithadd_rewrite_tag()! – EAMann♦ Apr 11 '12 at 15:58add_rewrite_tagshould probably be inside therewrite_photo_urlcallback... – Stephen Harris Apr 11 '12 at 16:00