[wp-hackers] WP_Rewrite query
Scott Merrill
skippy at skippy.net
Sun Feb 5 02:33:32 GMT 2006
Andy Skelton wrote:
> On 2/4/06, Scott Merrill <skippy at skippy.net> wrote:
>
>>I'm late to this discussion, because I've just realized that I'd like to
>>use a custom permalink structure for a project. Specifically, I want to
>>use semi-Julian dates (date('z') in PHP). I see how to insert the
>>query_var, and the regex is easy enough (/\d{3}/)m but I don't see how
>>to get in to manipulate WordPress' date variables.
>
>
> Once you've gotten your query var into $wp->query_vars, you can filter
> 'query_string' (classes.php line 1662). This is only one way to do it
> but it's the first one I thought of. Take your date out of the query
> string and replace it with the WP-recognized one.
>
> Buy me a beer,
Hold on there cowboy! ;) I'll be happy to buy you a beer, but...
I'm missing something. I want a new permalink structure to be applied
to posts. Instead of /%year%/%monthnum%/%day%/, I want to use
/%year%/%doy%/ where "doy" is Day of Year (date('z')). Calculating the
DoY is easy, but I don't know where to do it in order to make
get_permalink() use it.
Reversing the DoY into month+day is also (I think) fairly easy, but I'm
having trouble seeing where I'd slip it into the flow.
The examples I'm seeing all seem to assume some /tag/ prefix after which
will live the "stuff" for the permalink or query_var; but I don't want
/2006/doy/001 for January 2; I want plain ol' /2006/001. So I'm having
trouble modifying the examples for my needs.
I tried modifying Ryan's "Query Redirect Rewrite" plugin, but I could
never seem to get my query_var added to the list.
So, short of asking for someone to write my code for me, I would really
like to see a comprehensive example of how to add and use a new
permalink token -- assuming such can be done.
--
skippy at skippy.net | http://skippy.net/
gpg --keyserver pgp.mit.edu --recv-keys 9CFA4B35
506C F8BB 17AE 8A05 0B49 3544 476A 7DEC 9CFA 4B35
More information about the wp-hackers
mailing list