php - rewrite wordpress url from archive date to a specific page -
i trying use default archive calendar in wordpress show single page instead of archive.
the default link blog/2015/04/13
, point agenda/?dato=2015/04/13
.
i have tried best , stuck on following , cannot figure out why not working.
function custom_rewrite_basic() { add_rewrite_rule('blog/([0-9]{4})/([0-9]{2})/([0-9]{2})/', 'agenda/?dato=$matches[1]', 'top'); flush_rewrite_rules(); } add_action('init', 'custom_rewrite_basic');
edit: not work went in direction , put following in archive.php of theme.:
if(is_date()) { $year = get_query_var('year'); $monthnum = get_query_var('monthnum'); $day = get_query_var('day'); $pagelink=get_page_link (get_page_by_title( 'agenda' )) . "?dato=" . $year . "/" . $monthnum . "/" . $day; header("location: $pagelink",true,301); }
that did trick , more useful if needs it..
Comments
Post a Comment