Last active
January 28, 2017 00:44
-
-
Save tripflex/b1e78e8c898c7c387c43ac2adc4a0590 to your computer and use it in GitHub Desktop.
How to use a non-standard/hidden meta field for custom permalinks
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
// assuming the non-standard meta key is `job_import_id` (this filter is for Admin Side) | |
add_filter( 'job_manager_visibility_permalink_get_field_value_job_import_id_is_hidden_meta', 'smyles_job_import_id_permalink_not_hidden' ); | |
function smyles_job_import_id_permalink_not_hidden(){ | |
return false; | |
} | |
// This is for frontend handling | |
add_filter( 'job_manager_visibility_permalink_frontend_get_field_value_job_import_id', 'smyles_job_import_id_frontend', 10, 4 ); | |
/** | |
* Fontend Handling | |
* | |
* @var $value The value that is going to be returned and used for the permalink | |
* @var $all_fields All field configurations in array format | |
* @var $values All values in array format passed by core WP Job Manager plugin after validations | |
* @var $field_value Same as $value, unless unable to determine how to pull value, $value will be empty string and this will be the actual value | |
* | |
* @return string | |
*/ | |
function smyles_job_import_id_frontend( $value, $all_fields, $values, $field_value ){ | |
// It's up to you to return whatever value you want. Mainly because if the value was submitted via the form | |
// there would be no need to use this filter, as the plugin already handles it. This filter would be used to | |
// customize a value, or to return your own custom value. | |
return 'somecustomvalue'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment