You need to add following two functions in theme functions.php
or in a plugin’s php file
function func_rewrites_init(){
add_rewrite_rule(
'programme/(\d+)/(\d+)/?$',
'index.php?pagename=programme&pmonth=$matches[1]&pdate=$matches[2]',
'top' );
}
add_action('init', 'func_rewrites_init');
function func_query_vars( $query_vars ){
$query_vars[] = 'pmonth';
$query_vars[] = 'pdate';
return $query_vars;
}
add_filter( 'query_vars', 'func_query_vars' );
pagename
value in the above code have to be according to template name. If you have a Page
with slug programme
template name will be page-programme.php
. In that template file you can access month and date
$pmonth = get_query_var('pmonth');
$pdate = get_query_var('pdate');
One important thing from doc:
IMPORTANT: Do not forget to flush and regenerate the rewrite rules
database after modifying rules. From WordPress Administration Screens,
Select Settings -> Permalinks and just click Save Changes without any
changes.