How to use non-standard/hidden meta for custom permalinks

In WordPress, there are two types of meta values that can be saved to a listing (post), etc.  Hidden meta, and non-hidden meta.  Hidden meta is defined by being saved to a listing (post), with a prepended underscore.

In WP Job Manager, all meta is saved to the listing as hidden meta.  If you’ve used my Field Editor plugin, you should know what a meta key is, and as an example, let’s use the meta key job_salary .  When that field is saved to the listing, it’s actually saved under the _job_salary  meta key (notice the prepended underscore).

Note: if you’re using the field editor plugin, under the Debug tab in the Field Editor Settings page, you can enable “Post Meta Inspector”, once you enable that, goto the edit listing page in the admin section, scroll to the bottom, and voila, you can see all of the meta associated with that post/listing (if you’re not using Field Editor Plugin, you can install “Post Meta Inspector” from the plugin repository).

In the WP Job Manager Visibility plugin you have the option to use any available meta keys to generate your own custom permalink structures.  If you want to use a non-standard, non-hidden meta key (if you import the meta from somewhere else, etc), then you will need to use the filter described below, to define the meta key, as a non standard meta key.

Admin Filters

The filter to use is:



You can also use this filter which is available right after trying to set the value from the listing (post) object:


There is also this filter, which is called after processing taxonomies, and looping through field configuration trying to determine how to get the value.  This is filter called right before the value is returned:


Frontend Filters

Just like the filters above (which are for admin side handling), there are filters available for the frontend as well.




The taxonomy one above will only be called when the value is taxonomy.


Just make sure to replace METAKEY with the meta key that is non-standard.  For this example let’s assume our job_import_id  meta is non-standard (meaning it’s saved to the listing under job_import_id  not _job_import_id ), here’s the code you would need to add to your child theme’s functions.php file, or create and add inside a new code snippet using the Code Snippets plugin:


// 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';
Total 0 Votes

Tell us how can we improve this post?

+ = Verify Human or Spambot ?