[wp-hackers] Map a custom url to its content.
Otto
otto at ottodestruct.com
Wed May 19 20:22:52 UTC 2010
On Wed, May 19, 2010 at 2:42 PM, Alex Hempton-Smith
<hempsworth at googlemail.com> wrote:
> @Otto:
>
> I'm using the method you posted, and its working fine, but I'd like to do
> something else with this... how would I retrieve variables from the URL
> using pretty permalinks. Say I have the URL 'domain.com/person/2', how would
> I make the output on the page like:
>
> "The person ID you requested was 2"
Something like this in your plugin would do it, I think.
function add_person_url() {
add_rewrite_rule('person/([0-9]*)$', 'index.php?person=$matches[1]');
add_rewrite_tag('%person%', '[0-9]+');
}
add_action('init', 'add_person_url');
Later on in your template, after the query and such, you'd be able to
get the value of the person variable with this:
$person = get_query_var('person');
-Otto
More information about the wp-hackers
mailing list