Changing permalinks
-
Hello,
How to change wp job manager permalinks?
This takes all company description into my permalink. How to fix it?
I wan to see it like:
http://www.domain.com/job/job-category/job-name.
Thanks.
-
Anyways, I don’t understand how to delete these slugs from my permalink.
The https://wpjobmanager.com/document/tutorial-changing-the-job-slugpermalink/#section-3 section specifically is what you need. That filter will let you remove everything, so you can just leave the title there.
Yeah, i see it.
I don’t have any php code experience, so can you make the code for me? How to make only /job-category/job-name π
I’ve added a snippet to prepend the url with the category https://wpjobmanager.com/document/tutorial-changing-the-job-slugpermalink/#section-4
Where to add this code?
I tried to add it to functions.php, but then my website had an error.
I’ve updated the snippet, but yes. Functions.php. Ensure its wrapped in <?php ?> php tags.
Parse error: syntax error, unexpected ‘<‘ in ***********/public_html/wp-includes/functions.php on line 4449
`<?php
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’ );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’ );?>
Then it already has the <?php by the sounds of it. Remove them again.
After you’ve added the code correctly, go to Settings > Permalinks and save.
After adding this code:
domain.com/job/category/jobdescribe-jobtype-jobname/
I tried to save permalinks, but that’s changed nothing.
The code above is for prefixing the category to the URL, which is appears to have done?
Can I send you my theme functions.php file?
There are some other snippets in the doc I sent to you for changing the actual post slug rather than the permalink if thats what you want as well.
https://wpjobmanager.com/document/tutorial-changing-the-job-slugpermalink/#section-2
So by default, the job slug is:
company-name-job-location-type-title
This keeps the title unique.
Taking the snippet here: https://wpjobmanager.com/document/tutorial-changing-the-job-slugpermalink/#section-2 If you remove these lines:
// Prepend with company name if ( ! empty( $values['company']['company_name'] ) ) $job_slug[] = $values['company']['company_name']; // Prepend location if ( ! empty( $values['job']['job_location'] ) ) $job_slug[] = $values['job']['job_location'];It will simply use the job title and nothing else.
If you’re struggling or want something more custom that the snippets I’ve provided, try jobs.wordpress.net and get a dev to code something up specific to your needs.
Ok i’m deleted these from class-wp-job-manager-form-submit-job.php
but then in submission showed and error:
Warning: include(………………../wp-content/plugins/wp-job-manager/templates/form-fields/job-category-field.php): failed to open stream: No such file or directory in …………../wp-content/plugins/wp-job-manager/wp-job-manager-template.php on line 26
You may have made a mistake editing those core files. The snippet above/in the doc goes in theme functions.php – do not edit core files
I suggest you reupload a clean version of the plugin and add the function/filter to your theme functions.php instead as instructed.
The topic ‘Changing permalinks’ is closed to new replies.