Support » Plugin: WP Job Manager » Get job category slug

  • Resolved dnextreme88

    (@dnextreme88)


    How do I get the job category’s slug? Is there a function for this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support bindlegirl

    (@bindlegirl)

    Hi @dnextreme88 !

    You can see the job category slugs in the WP-Admin on the Job Categories page. Is that what you are looking for?

    Thread Starter dnextreme88

    (@dnextreme88)

    No, I’m adding custom code to the WP Job Manager plugin as it fails to include job categories on the [job_dashboard] shortcode. I changed the attribute being plucked by the wp_list_pluck function from name to slug. For anyone who wishes to do the same thing as I did, here’s the code I have. Place this on wp-job-manager.template.php:

    function wpjm_job_categories_slug ( $post = null, $separator = ', ' ) {
    	if ( ! get_option( 'job_manager_enable_categories' ) ) {
    		return;
    	}
    
    	$job_categories = wpjm_get_the_job_categories( $post );
    
    	if ( $job_categories ) {
    		$names = wp_list_pluck( $job_categories, 'slug' );
    		$slugs = esc_html( implode( $separator, $names ) );
    	}
    	return $slugs;
    }

    On class-wp-job-manager-shortcodes.php, search for $job_dashboard_columns variable and appending this key-value in the params (place it anywhere, I placed it before the filled key. This variable will be looped and will append the keys in order, I simply wanted it after the job title but before the Filled column anyway):

    $job_dashboard_columns = apply_filters('job_manager_job_dashboard_columns',
    			[
    				'job_title' => __( 'Job Title', 'wp-job-manager' ),
    				'category'  => __( 'Category', 'wp-job-manager' ),
    				'filled'    => __( 'Filled?', 'wp-job-manager' ),
    				'date'      => __( 'Date Created', 'wp-job-manager' ),
    				'expires'   => __( 'Listing Expiration', 'wp-job-manager' ),
    			]
    		);

    On job-dashboard.php, I placed this code before <?php elseif ('date' === $key ) : ?> to display the categories (I have made a custom code to get the name of each category and insert a link to their respective pages).

    <?php elseif ('category' === $key ) : ?>
      <div style="text-align: center;"><?php echo '<a href=" ' .get_home_url(). '/category-' .wpjm_job_categories_slug( $job ).'" >' .wpjm_job_categories_name( $job ).'</a>'?></div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.