mod rewrite - Rewriting URLs in WordPress not working for this scenario -


i have been trying rewrite specific rule in wordpress, seems simple can't work.

current url: topic/?topic_id=155&title=life-balance 

and

desired url: topic/155/life-balance 

i have little knowledge of url rewriting, infect first time rewriting urls. have tried

in functions.php file

add_action( 'init', 'add_seourl_rules' ); function add_seourl_rules() {      add_rewrite_rule(         "topic/([^/]+)/([^/]+)/?",         "topic/?topic_id=$matches[1]&title=$matches[2]",         "top"); } 

after adding function, re-saved permalinks flush urls, still not working.

any ideas doing wrong here. thanks

edit 1:

ok, have made these changes still not working.

*step 1:*  

my permalink set %%postname%% in wp permalinks. changed them normal (?p=123).

***step 2:***  

as of now, normal pages , posts plain urls.

normal pages: example.com/?page_id=717  normal posts: example.com/?p=2470  custom post: example.com/?page_id=717&topic_id=155&title=life-balance   ***`step 3`*** 

to rewrite custom post url, have changed function this.

add_action( 'init', 'add_seourl_rules' ); function add_seourl_rules() {      add_rewrite_rule(         '^topics/([^/]+)/([^/]+)/?',         'index.php?page_id=717&topic_id=$matches[1]&title=$matches[2]',         'top'); } 

still can't make work custom post, , not sure should normal pages , posts.


Comments