Rewrite rule in wordpress plugin for permalink
-
0
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=100Of course i want that visitor stay at url site.com/items/blabla/100/
Any solutions? Thanks
Pedja
-
Hi there, I took a look at your account here, but I don’t see any sites under it.
What is the URL of the site with the problem?
Once we know that, we should be able to help or at least direct you to the folks who can.
-
Hello Macmanx,
Thank you for your reaction.
there is no active site, only local test envoriment for plugin.Regards
-
Hi Pedja,
In that case it’s best if you ask in the WordPress Development forum over on WordPress.org instead:
https://wordpress.org/support/forum/wp-advanced/
Alternatively you can also try https://wordpress.stackexchange.com/
The forum you’re posting to now is for end-users of free sites hosted on WordPress.com. Neither our users nor our support staff in this forum are developers, so I’m afraid helping with this is far beyond our collected expertise :)
-
Hi,
thanks! Sorry about posting in the wrong forum. You can close/delete this topic
.
Regards
- The topic ‘Rewrite rule in wordpress plugin for permalink’ is closed to new replies.