Permalink using Location
-
Hi I’m trying to follow this tutorial
And my goal is to create permalinks – website.com/jobs/location/id/name
Tutorial in documentation is pretty well written but with my limited knowledge of PHP I haven’t been able to make it work.I used this part of code to add jobs is to the base url. But I struggle with adding location.
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'] = 'job/%post_id%'; return $args; } add_filter( 'register_post_type_job_listing', 'change_job_listing_slug' );
How would you create website.com/job/location/id/job-title structure ?
All help is appreciated.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Permalink using Location’ is closed to new replies.