How to change the URL using rewrite rule in wordpress
-
My question is simple I have this URL
http://example.com/aircraft-gallery/aircraft-gallery-class/?id=VIP Airlinerand I want this URLhttp://example.com/aircraft-gallery/VIP-AirlinerI put this code in my functions.php file but it’s not working I don’t know whyadd_filter( 'query_vars', 'wpa5413_query_vars' ); function wpa5413_query_vars( $query_vars ) { $query_vars[] = 'id'; return $query_vars; } add_action( 'init', 'wpa5413_init' ); function wpa5413_init() { add_rewrite_rule( 'aircraft-gallery-class/([^/]+)/?', 'index.php?pagename=aircraft-gallery-class&id=$matches[1]', 'top' ); }I have already tried many codes suggested by the community but it does not work.
Any help would be greatly appreciated. I am clicking saving permalinks every time I update the functions.php file. Thanks
-
Hi @shehzad171, you’ll want to try the forums for self-managed sites over at https://wordpress.org/support . These one are for sites managed and hosted by WordPress.com.
- The topic ‘How to change the URL using rewrite rule in wordpress’ is closed to new replies.