I’m working with WordPress and have created a page called “single-staff.” The URL https://example.com/single-staff works fine, but accessing https://example.com/single-staff/12/abc results in a 404 error. I added some code to the function.php
file and rebuilt the permalinks, but the issue persists.
`
add_filter(‘query_vars’, ‘gp_gotcha_queryvars’ );
function gp_gotcha_queryvars( $qvars ){
$qvars[] = 'id';
$qvars[] = 'name';
return $qvars;
}
add_action( ‘init’, ‘gp_rewrite_url’);
function gp_rewrite_url(){
add_rewrite_rule(
'single-staff/([^/]*)/?([^/]*)/?([^/]*)/?',
'index.php?pagename=single-staff&id=$matches[1]&name=$matches[2]',
'top'
);
//flush_rewrite_rules();
}`
any issue
I want to be able to access URLs in the format https://example.com/single-staff/12/abc and capture the parameters 12 and abc.