Programmatically Create Job Post
-
I am trying to programmatically create jobs and I’d like to use any WP Job Manager API functions if they are available. Is there a convenience function to create jobs? Something like:
WP_Job_Manager::add_job($job_data);
I know I can do the following but a forward compatible way would be to use your API function so it sets all needed post meta that I might not know about and so it sets the correct value format for searching and etc.
`$job_data = [
‘post_title’ => $post_title,
‘post_content’ => $post_content,
‘post_type’ => ‘job_listing’,
‘comment_status’ => ‘closed’,
‘post_name’ => $post_title,
];$id = wp_insert_post( $job_data );
$job_meta = [
‘_company_x’ => ‘foo’,
‘_job_x’ => ‘foo’,
…
];foreach ($job_meta as $key) {
update_post_meta($id, $key, $job_meta[$key]);
}`
- The topic ‘Programmatically Create Job Post’ is closed to new replies.