I have a specific URL-function that returns proper pretty URLs for my own plugin that I want to use for 301-redirecting.
So what I need to do is take
/groups/123_ABC
and pass
123
into my function
getPrettyURL(123)
So I thought I could do:
add_rewrite_rule('^/groups/(?:.+/)?(d+)/?$', getPrettyURL($matches[1]), 'top');
but that does not work. What’s wrong?
Looking at the Rewrite API provided by WordPress; I see that you don’t want the leading
/
in your regex.Try