I have a Wordpress site that is built to be a job listing board, and I'm looking to create SEO friendly URLs based on data that is stored in the database.
The URL structure should include the state abbreviation, city, and job title, and result in the following format: www.domain.com/job/ca/sacramento/janitor
There is currently a "Job" page in the backend that uses custom page template located at 'page-templages/job-template.php' that displays the database information at the following URL: www.domain.com/job/?2020-412341235134
How can I display the www.domain.com/job/?2020-412341235134 at the friendly virtual URL www.domain.com/job/ca/sacramento/janitor.
Here's how I'm accessing the database information in my current page template.
$job_title = $job[0]['job_title'];
$sanitized_job_title = str_replace(" ", "-", $job_title);
$bloginfo_url = get_bloginfo('url');
$friendly_url = $bloginfo_url . '/job/'. $job[0]['city'].'/'. $job[0]['state'] .'/'. $sanitized_job_title;
I've read through the add_rewrite_rule() documentation, and can't seem to get my head around it.
Any help would be greatly appreciated.