apply_filters( ‘jobrelay_wpcon_update_job_post_args
‘, $args array, $job_data array )
In this article
Filters the array of arguments that is passed to the wp_update_post
function when a new job is to be created and the slug is updated. At this point we already have a post ID for the new job.
Parameters
$post
WP_Post
The current post object$update
bool
Whether this is a update (true) or a save (false)
More information
The filter is passed the array of arguments used by wp_update_post
and therefore any of these arguments can be used.
Example usage
The following example uses this filter in order to change the newly created job URL to use the job reference as the post slug, rather than the job title.
For a job titled “Marketing Manager London”, usually the slug would be marketing-manager-london
whereas this plugin would ensure that the slug is just the job reference.
/**
* Edits the URL of jobs to just use the reference.
*
* @param array $args The args to update.
* @param int $post_id The post ID.
* @param array $job_data The job data array.
*/
function hd_jobrelay_edit_job_urls( $args, $post_id, $job_data ) {
// get the reference.
$ref = $job_data['job_reference'];
// if we don't have a reference, return the args.
if ( empty( $ref ) ) {
return $args;
}
// set the reference.
$args['post_name'] = $ref;
// return the args.
return $args;
}
add_filter( 'jobrelay_wpcon_update_job_post_args', 'hd_jobrelay_edit_job_urls', 10, 3 );
This can be placed in your active themes functions.php
file or be added as part of a plugin.