Title: rewrite permalink rules
Last modified: August 22, 2016

---

# rewrite permalink rules

 *  Resolved [bryceondemand](https://wordpress.org/support/users/bryceondemand/)
 * (@bryceondemand)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/rewrite-permalink-rules/)
 * I am trying to do same thing in this documentation for company instead: [https://wpjobmanager.com/document/tutorial-add-meta-data-resume-permalinks/](https://wpjobmanager.com/document/tutorial-add-meta-data-resume-permalinks/)
 * I am unable to get this working. Could you take a look at this and see what I
   am doing wrong?
 *     ```
       function add_job_rewrite_rules(){
       	add_rewrite_tag( '%job%', '([^/]+)', 'job=' );
       	add_rewrite_tag( '%company_title%', '([^/]+)', 'company_title=' );
       	add_permastruct( 'job', 'jobs/%company_title%/%job%', true );
       }
       add_action( 'init', 'add_job_rewrite_rules', 11 );
   
       /**
        * Add data to the permalinks
        * @param  string $permalink
        * @param  WP_Post $post
        * @param  bool
        * @return string
        */
       function job_permalinks( $permalink, $post, $leavename ) {
       	// Only affect resumes
       	if ( $post->post_type !== 'job' || empty( $permalink ) || in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
       		return $permalink;
       	}
   
       	// Get the meta data to add to the permalink
       	$title = get_post_meta( $post->ID, '_company_name', true );
   
       	// We need data, so fallback to this if its empty
       	if ( empty( $title ) ) {
       		$title = 'company';
       	}
   
       	// Do the replacement
       	$permalink = str_replace( '%company_title%', sanitize_title( $title ), $permalink );
   
       	return $permalink;
       }
       add_filter( 'post_type_link', 'job_permalinks', 10, 3 );
       ```
   
 * [https://wordpress.org/plugins/wp-job-manager/](https://wordpress.org/plugins/wp-job-manager/)

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

 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/rewrite-permalink-rules/#post-5865460)
 *     ```
       function add_job_rewrite_rules(){
       	add_rewrite_tag( '%job_listing%', '([^/]+)', 'job_listing=' );
       	add_rewrite_tag( '%company_title%', '([^/]+)', 'company_title=' );
       	add_permastruct( 'job_listing', 'jobs/%company_title%/%job_listing%', true );
       }
       add_action( 'init', 'add_job_rewrite_rules', 11 );
   
       /**
        * Add data to the permalinks
        * @param  string $permalink
        * @param  WP_Post $post
        * @param  bool
        * @return string
        */
       function job_permalinks( $permalink, $post, $leavename ) {
       	// Only affect resumes
       	if ( $post->post_type !== 'job_listing' || empty( $permalink ) || in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
       		return $permalink;
       	}
   
       	// Get the meta data to add to the permalink
       	$title = get_post_meta( $post->ID, '_company_name', true );
   
       	// We need data, so fallback to this if its empty
       	if ( empty( $title ) ) {
       		$title = 'company';
       	}
   
       	// Do the replacement
       	$permalink = str_replace( '%company_title%', sanitize_title( $title ), $permalink );
   
       	return $permalink;
       }
       add_filter( 'post_type_link', 'job_permalinks', 10, 3 );
       ```
   
 *  Thread Starter [bryceondemand](https://wordpress.org/support/users/bryceondemand/)
 * (@bryceondemand)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/rewrite-permalink-rules/#post-5865517)
 * Thanks Mike. This did something, the url changed but I now have a page that tells
   me that it cannot be found. That goes for all job posts.
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/rewrite-permalink-rules/#post-5865573)
 * You must go to Settings > Permalinks and save or it won’t work.

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

The topic ‘rewrite permalink rules’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/rewrite-permalink-rules/#post-5865573)
 * Status: resolved