Title: About changing the permalink structure
Last modified: August 22, 2016

---

# About changing the permalink structure

 *  Resolved [andypp](https://wordpress.org/support/users/andypp/)
 * (@andypp)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/about-changing-the-permalink-structure/)
 * Hi,
 * I read your tutorial on changing the job’s permalink, but I can’t figure out 
   how to do this (sorry, I know nothing about php). I’d like job_listing_category
   and job_listing_region to show in the URL before the listing name. I added the
   following to my functions.php, the job region shows in the URL but the job category
   doesn’t:
 *     ```
       function job_listing_post_type_link( $permalink, $post ) {
           // Abort if post is not a job
           if ( $post->post_type !== 'job_listing' )
           	return $permalink;
   
           // Abort early if the placeholder rewrite tag isn't in the generated URL
           if ( false === strpos( $permalink, '%' ) )
           	return $permalink;
   
           // Get the custom taxonomy terms in use by this post
       	$terms = get_the_terms( $post->ID, 'job_listing_category' );
       	$terms = get_the_terms( $post->ID, 'job_listing_region' );
   
       	if ( empty( $terms ) ) {
       		// If no terms are assigned to this post, use a string instead (can't leave the placeholder there)
       		$job_listing_category = _x( 'uncat', 'slug' );
       	} else {
       		// Replace the placeholder rewrite tag with the first term's slug
       		$first_term = array_shift( $terms );
       		$job_listing_category = $first_term->slug;
       	}
   
           $find = array(
           	'%category%'
           );
   
           $replace = array(
           	$job_listing_category
           );
   
           $replace = array_map( 'sanitize_title', $replace );
   
           $permalink = str_replace( $find, $replace, $permalink );
   
           return $permalink;
       }
       add_filter( 'post_type_link', 'job_listing_post_type_link', 10, 2 );
   
       function change_job_listing_slug( $args ) {
         $args['rewrite']['slug'] = 'job/%category%';
         return $args;
       }
       add_filter( 'register_post_type_job_listing', 'change_job_listing_slug' );
       ```
   
 * What am I doing wrong?
 * [https://wordpress.org/plugins/wp-job-manager/](https://wordpress.org/plugins/wp-job-manager/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [andypp](https://wordpress.org/support/users/andypp/)
 * (@andypp)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/about-changing-the-permalink-structure/#post-5822948)
 * Basically, the url structure should be: mywebsite.com/jobs/job_listing_region/
   job_listing_category/name
 *  [Scott Basgaard](https://wordpress.org/support/users/scottbasgaard/)
 * (@scottbasgaard)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/about-changing-the-permalink-structure/#post-5823063)
 * Hey Andy,
 * You’d first want to add the region to the slug structure:
 *     ```
       function change_job_listing_slug( $args ) {
         $args['rewrite']['slug'] = 'job/%region%/%category%';
         return $args;
       }
       add_filter( 'register_post_type_job_listing', 'change_job_listing_slug' );
       ```
   
 * You can then try another filter on ‘post_type_link’ similar to the category one
   here:
    – [https://wpjobmanager.com/document/tutorial-changing-the-job-slugpermalink/#section-4](https://wpjobmanager.com/document/tutorial-changing-the-job-slugpermalink/#section-4)
 * 1. Instead of job_listing_category us job_listing_region
    2. Instead of searching
   for %category% us %region%
 * I’m not sure what / if any rewrite rule issues you’d run into if any with this
   structure though but hope this helps point you in the right direction.
 * Kind Regards,
    Scott
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/about-changing-the-permalink-structure/#post-5823066)
 * I’m having no luck doing this – I’m not sure if its a WP issue. Using %category%
   for the replacement works, but anything else breaks.
 * If you can do without both region and category, just swap out job_listing_category
   with job_listing_region in the original snippet.
 *  Thread Starter [andypp](https://wordpress.org/support/users/andypp/)
 * (@andypp)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/about-changing-the-permalink-structure/#post-5823130)
 * Alright, thanks both.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘About changing the permalink structure’ is closed to new replies.

 * ![](https://ps.w.org/wp-job-manager/assets/icon-256x256.gif?rev=2975257)
 * [WP Job Manager](https://wordpress.org/plugins/wp-job-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-job-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-job-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-job-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-job-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-job-manager/reviews/)

## Tags

 * [permalinks](https://wordpress.org/support/topic-tag/permalinks/)
 * [url](https://wordpress.org/support/topic-tag/url/)

 * 4 replies
 * 3 participants
 * Last reply from: [andypp](https://wordpress.org/support/users/andypp/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/about-changing-the-permalink-structure/#post-5823130)
 * Status: resolved