Last active
November 12, 2018 22:22
-
-
Save maciejbis/397ea8358d54a837193eb99645291014 to your computer and use it in GitHub Desktop.
WP Job Manager Field Editor - support custom fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function pm_replace_job_meta_tags($default_uri, $native_slug, $element, $slug, $native_uri) { | |
if(function_exists('get_job_field') && !empty($element->ID)) { | |
$fields = array( | |
'first-field', // in Permalink Manager Permastructures settings it will be '%__first-field%' | |
'second-field' // in Permalink Manager Permastructures settings it will be '%__second-field%' | |
); | |
foreach($fields as $field) { | |
$raw_field_value = get_job_field($field, $element->ID); | |
$field_value = Permalink_Manager_Helper_Functions::sanitize_title($raw_field_value); | |
$default_uri = (!empty($custom_field_value)) ? str_replace("%__{$field}%", $field_value, $default_uri); | |
} | |
} | |
return $default_uri; | |
} | |
add_filter('permalink_manager_filter_default_post_uri', 'pm_replace_job_meta_tags', 9, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment