WordPress Custom URL Rewrites
I do something similar with custom records called shops and their specific ID number. In my case I want http://example.com/shops/UNIDrecordthatsreallylong to load with the variable shop_unid being the UNID record. Here’s my working function: //Shop page rewrites function shop_rewrite() { add_rewrite_rule(‘^shops/([^/]*)/?’,’index.php?pagename=shops&shop_unid=$matches[1]’,’top’); add_rewrite_tag(‘%shop_unid%’,'([^&]+)’); } add_action(‘init’, ‘shop_rewrite’); Note that I used pagename instead of the post number. … Read more