Created
April 16, 2020 16:58
-
-
Save n7studios/8a811cc0f2e8c4cf55a2229be5e2e99b to your computer and use it in GitHub Desktop.
WordPress to Buffer Pro: Broadbean XML Feed: Define Featured Image on new imported Jobs
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 | |
/** | |
* Plugin Name: WordPress to Buffer Pro: Broadbean XML Feed: Define Featured Image on new imported Jobs | |
* Plugin URI: http://www.wpzinc.com/ | |
* Version: 0.0.1 | |
* Author: WP Zinc | |
* Author URI: http://www.wpzinc.com | |
* Description: Example code of a possible implementation for defining WordPress to Buffer Pro's Featured Image for a Job Post created from Broadbean's XML feed | |
*/ | |
/** | |
* Example code of a possible implementation for defining WordPress to Buffer Pro's Featured Image for a Job Post created from Broadbean's XML feed | |
* | |
* @since 0.0.1 | |
* | |
* @param array $insert_job_args wp_insert_post() compatible arguments used to add a Job Post from the Broadbean XML feed | |
* @param object $xml Broadbean XML Job data | |
* @return array $insert_job_args wp_insert_post() compatible arguments used to add a Job Post from the Broadbean XML feed | |
*/ | |
function wp_to_buffer_pro_broadbean_featured_image_new_job( $insert_job_args, $xml ) { | |
// Determine the WordPress Media Library Image ID you want to use | |
// This must be an image that's already in WordPress' Media Library - so if you | |
// need to fetch an image from somewhere and store it in the Media Library for this Job, do | |
// so now. | |
$image_id = 1; | |
// Set the above Image ID as WP to Buffer Pro's Featured Image, as Jobs | |
// don't support Featured Images | |
$insert_job_args['meta_input'] = array( | |
'wp-to-buffer-pro' => array( | |
'featured_image' => $image_id, | |
), | |
); | |
// Return the wp_insert_post() arguments | |
return $insert_job_args; | |
} | |
add_filter( 'wpbb_insert_job_post_args', 'wp_to_buffer_pro_broadbean_featured_image_new_job', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment