[wp-hackers] some problem with understanding wp_rewrite
Dagan Henderson
Dagan.Henderson at epyllion.com
Thu Oct 13 15:32:16 UTC 2011
Why not add the query vars via the GET/POST request itself? For example, http://example.com/post/hellow-world/something/?partner=1234.
That would make the partner ID accessible via $_REQUEST['partner'] without impacting the WP query.
-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Konrad Karpieszuk
Sent: Thursday, October 13, 2011 6:01 AM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] some problem with understanding wp_rewrite
thank you :) it looks like something what i need :)
and more question: what if i have some plugin which also use add_rewrite_endpoint to add for example endpoint 'something'?
urls like
example.com/post/hello-world/something/smth-from-plugin/partner/1234
and
example.com/post/hello-world/partner/1234/something/smth-from-plugin
still will work? both of them?
On Thu, Oct 13, 2011 at 2:18 PM, Ozh <ozh at ozh.org> wrote:
> I think what you need is a nice illustration of custom endpoints See
> http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint
>
> That would be something like:
>
> // Add the endpoint rewrite rules
> add_filter( 'init', 'ozh_ep_add_rules' ); function ozh_ep_add_rules()
> {
> add_rewrite_endpoint( 'partner', EP_ALL ); // add endpoint on all
> pages }
>
> // Add permalink structure and flush on plugin activation
> register_activation_hook( __FILE__, 'ozh_ep_activate' ); function
> ozh_ep_activate() {
> ozh_ep_add_rules();
> flush_rewrite_rules();
> }
>
> // Handle the partner id early
> add_filter( 'template_redirect', 'ozh_ep_template_redirect' );
> function ozh_ep_template_redirect() {
> $partner = get_query_var( 'partner' );
> // do something with $partner
> // ...
> }
>
> HTH
>
> Ozh
>
> --
> http://ozh.org/ - @ozh on Twitter
> WordPress plugins? I wrote a book! http://amzn.to/plugindevbook
>
>> hello
>>
>> I spent all last night reading codex and tutorials but i still don't
>> understand how to do this.
>>
>> I run online shop on wordpress and now i want to create affiliate
>> program. I will tell to affiliate partners that if someone of them
>> want to publish referral link on their website, then they have to
>> take any link from my shops' website and add /partner/1234 at the
>> and, where '1234' is id of partner
>>
>> OK, but how to manage this in wordpress? How to register this rewrite
>> rule that 'any webpage which has "/partner/(.*?)" at end should be
>> redirected to version without this (or even it can stay) and to
>> query_vars[] will be added 'partner''?
>>
>> "Any" means that partner can publish somewhere links like:
>> example.com/partner/1234
>> example.com/blog/hello-world/partner/1234
>> example.com/archive/january/partner/1234
>> example.com/static-page/partner/1234
>>
>> and any other variations which i cant even imagine right now :)
>>
>> --
>> (en) regards / (pl) pozdrawiam
>> Konrad Karpieszuk
>> http://tradematik.pl wtyczka do WordPressa do tworzenia sklepów dla
>> klientów z Polski _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
--
(en) regards / (pl) pozdrawiam
Konrad Karpieszuk
http://tradematik.pl wtyczka do WordPressa do tworzenia sklepów dla klientów z Polski _______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list