I would like to add parameter to custom post type posts

So I need to do my url like that. http://www.mywebsite.com/mycpt-slug/post-slug/myparameter

I found this solution but here it's work with post ID, how can I do this to work whit post id?

Why does rewrite rule work for page not for custom post type post?

1 Answer 1


I found the solution.

function add_rewrite_rules($rules) {
$newrules = array('cpt-slug/([^/]+)/([^/]+)/?$' => 'index.php?name=$matches[1]&post_type=cpt_name&member_view=$matches[2]');
$rules = $newrules + $rules;
return $rules;


You just need to change 'p' to 'name'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.