Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter frytec

    (@frytec)

    or even better…

    like this would be great:

    mysite.com/vaga/job-title

    (only job title in url, no company name).

    Hello,

    You can use the code if you like, it will change JOB into what you want and also add post ID

    It will be like yourdomain/job/job-id/post-title

    unfortunately i dont know how to remove company name from post-title

    While i dont have a problem with company-name, i do have a problem with location name appearing in the url, don’t know how to remove that …

    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;
    
        $find = array(
        	'%post_id%'
        );
    
        $replace = array(
        	$post->ID
        );
    
        $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'] = 'YOURTEXT/%post_id%';
      return $args;
    }
    add_filter( 'register_post_type_job_listing', 'change_job_listing_slug' );

    Ah yeah, add it in your functions.php

    Thread Starter frytec

    (@frytec)

    This is VERY good, man… Thanks for sharing your wisdom… I really appreciate it… hopefully someone will help us on how to remove company and location from the job url…

    Thread Starter frytec

    (@frytec)

    hey chandersbs, to remove company-name and job-region from job-slug try using this (it should use only the job-title as job-slug):

    add_filter( 'submit_job_form_save_job_data', 'custom_submit_job_form_save_job_data', 10, 5 );
    
    function custom_submit_job_form_save_job_data( $data, $post_title, $post_content, $status, $values ) {
    
      $job_slug = array();
    
      $job_slug[] = $post_title; 
    
      $data['post_name'] = implode( '-', $job_slug );
    
      return $data;
    }
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Replace JOB in URL for something else’ is closed to new replies.