Creating a custom rewrite for a single page
I am quite new to working within wordpress but am getting along quite smoothly.
I have setup a website where its downloading external JSON data from rapid-api and then displaying them in my design. The data is about Football/Soccer teams.
I have setup a page that is url/team-info/?id=123
In here its fetching the id from the url and downloading that specific teams information from the json.
That all works perfectly, but I am having to use a PHP snippet plugin in order for it to work.
I then wanted to create a rewrite rule to change it from url/team-info/?id=123
to url/team-info/123
I originally tried editing the htaccess file directly but that threw up all sorts of 500 errors, so I put the original back and left it as it was.
I then have seen lots of posts about adding in code like so into the ‘init hook’, something I am not familiar with in wordpress, back to 2013 and 2014, I am sure these will be out dated so am looking for guidance.
So far I have learned the page in question is /?page_id=735
which then ?page_id=735&id=123
also works.
I look forward to your guidance on this matter and if you have any furtur questions please let me know.
Leave an answer