Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Thread Starter Edvinas L

    (@edvinas-l)

    Anyways, I don’t understand how to delete these slugs from my permalink.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    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.

    Thread Starter Edvinas L

    (@edvinas-l)

    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 ??

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    I’ve added a snippet to prepend the url with the category https://wpjobmanager.com/document/tutorial-changing-the-job-slugpermalink/#section-4

    Thread Starter Edvinas L

    (@edvinas-l)

    Where to add this code?

    I tried to add it to functions.php, but then my website had an error.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    I’ve updated the snippet, but yes. Functions.php. Ensure its wrapped in <?php ?> php tags.

    Thread Starter Edvinas L

    (@edvinas-l)

    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’ );

    ?>

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    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.

    Thread Starter Edvinas L

    (@edvinas-l)

    After adding this code:

    domain.com/job/category/jobdescribe-jobtype-jobname/

    I tried to save permalinks, but that’s changed nothing.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    The code above is for prefixing the category to the URL, which is appears to have done?

    Thread Starter Edvinas L

    (@edvinas-l)

    Can I send you my theme functions.php file?

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    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.

    Thread Starter Edvinas L

    (@edvinas-l)

    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

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    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.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Changing permalinks’ is closed to new replies.