After reading the responses to my last post, it became clear to me that what I thought was a cry for help just sounded to others as whingeing. And re-reading the post, it was clear to me that y’all were right.
So, let me try again with our biggest pain: incoming links.
Our existing incoming links are in the format
WordPress, apparently, needs that URL to be*
That is, we have the year, month, and dayâ€”but what we need is the year and week number. That nn is the nth week of the year. So we have a URL that comes in looking like (for example)
and we then want WP to serve up
As I see it, there’s two ways that WP could handle this*: either redirection, or permalinks for weekly archives.
Redirection: I can’t figure out how to do this given that nn in the code above. A redirect would have to take in a date and turn it into a week number, and I don’t believe that’s possible*.
Permalinks: I was hoping that there was a plugin that creates pretty permalinks for weekly archives, but I haven’t found one as yet*.
That meansÂ that I have to write a custom query*, and here’s what I’ve got so far:
$day = substr( $datestr, 8, 2 );
$month = substr( $datestr, 5, 2 );
$year = substr( $datestr, 0, 4 );
$timestamp = mktime( 0, 0, 0, $month, $day, $year );
$week = date( "W", $timestamp );
query_posts( 'nopaging=true&orderby=date&order=ASC&posts_per_page=-1&year=' . $year . '&w=' . $week );
The problem is that I have no idea where to put it, and no idea how to make it happen only when the URL is in the above format.
I’m still hoping that there’s an easy way to do this, and if I’ve got to use my own code in a child theme, I think I can now handle thatâ€”it’s just I’m not clear on the details of where/when it gets called.
Thanks in advance for any help you can give!
* This is to the best of my understanding, which means I could well be wrongâ€”if I am, please let me know.