I want to change the structure of yearly/monthly archive URL of default post type 'post'
.
As we know be default the URLs are like:
Default: http://wwww.domain.com/2013/09
but want them rewritten, so end up like this:
New: http://wwww.domain.com/about/blog/archive/2013/09
i tried following but do seem to work:
add_rewrite_rule("about/blog/archive/([0-9]{4})/([0-9]{2})/page/?([0-9]{1,})/?",'index.php?post_type=post&year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]','top');
add_rewrite_rule("about/blog/archive/([0-9]{4})/([0-9]{2})/?",'index.php?post_type=post&year=$matches[1]&monthnum=$matches[2]','top');
add_rewrite_rule("about/blog/archive/([0-9]{4})/page/?([0-9]{1,})/?",'index.php?post_type=post&year=$matches[1]&paged=$matches[2]','top');
add_rewrite_rule("about/blog/archive/([0-9]{4})/?",'index.php?post_type=post&year=$matches[1]','top');
I’d like someone to point to the right direction, need more info do leave a comment.
thanks.
You can do this without adding rewrite rules by changing the
$date_structure
of the$wp_rewrite
instance of theWP_Rewrite
class:Visit your Permalinks settings page after adding this code to flush the rewrite rules.