I am making an attempt rewrite url for permalink on single publish
my permalink: /%postname%/
My single kind: http://instance.com/abc-def/?chapter=1
adc-def imply: %postname%
i need permalink is: http://instance.com/abc-def/chapter/1
However it’s not doable.
that is my code:
add_action( 'init', 'myblog_rewrites_init' );
operate myblog_rewrites_init(){
add_rewrite_rule(
'([^/]+)/([0-9]+)/?$',
'index.php?title=$matches[1]&chapter=$matches[2]',
'prime' );
}
add_filter( 'query_vars', 'myblog_rewrite' );
operate myblog_rewrite( $query_vars ){
$query_vars[] = 'chapter';
return $query_vars;
}
Please assist me! Thanks each physique!