Query Vars for the Homepage?

I’d like to make the homepage accept query vars for year, month and date while still keeping the custom permalink structure for the rest of the site.

Basically the homepage needs to display several different links that are managed via custom posts.

Read More

So my hope is that
http://mysite.com – will display the links set for the current day but then also enable
http://mysite.com/2013/08/10/ – will display the links associated from that day as a type of archives. I need these as variables so I can do several different queries to display the relevant info.

Is this even possible, or am I attacking this the wrong way?
Will this mess up other pages trying to use the permalink structure?

I’ve attempted to set my own query vars

    add_filter( 'query_vars', 'wpse12965_query_vars' );
function wpse12965_query_vars( $query_vars )
{
    $query_vars[] = 'a_year';
    $query_vars[] = 'a_month';
    $query_vars[] = 'a_day';
    return $query_vars;
}

add_rewrite_rule(
     '^/([^/]*)/([^/]*)/([^/]*)/?',
     'index.php?page_id=5&a_year=$matches[1]&a_month=$matches[2]&a_day=$matches[3]',
     'top');

My vars are recognized but it always redirects to the 404 not found page.
Any suggestions would be greatly appreciated.

Edit
So anyone else who may be checking this out I’ll just mention that using the date.php template sorted this out and then I am easily able to retrieve the needed date vars like so

$day = (get_query_var('day'));
$year = (get_query_var('year'));
$monthnum = (get_query_var('monthnum')); 

Related posts

1 comment

Comments are closed.