I have plugin which is active on de page (permalink):
site.com/plugininfo/?item_id=100
I want to add in plugin rewrite rule for this url’s:
site.com/items/blabla/100/
“blabla” will be each time different.
I have tried different solutions but without success.
function when_rewrite_rules( $wp_rewrite ) {
$new_rules = array();
$new_rules['items/([^/]+)/([^/]+)/?$'] = 'plugininfo/?item_id=$matches[2]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_filter('generate_rewrite_rules','when_rewrite_rules');
seems that you can not rewrite url to direct to the permalink?
if I change code to
$new_rules['items/([^/]+)/([^/]+)/?$'] = 'index.php?p=500&item_id=$matches[2]';
500 is id of page, then is working but visitor get redirected from site.com/items/blabla/100/ to site.com/plugininfo/?item_id=100
Of course i want that visitor stay at url site.com/items/blabla/100/
Any solutions?
Thanks
Pedja