Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This snippets allows EE events/venues to use the feature image as the 'header image' within the Alone theme.
<?php // Please do not include the opening PHP tag if you already have one.
function alone_theme_add_header_image_to_ee_cpts($post_id, $post, $update) {
if (isset($_REQUEST['action'])
&& (
$_REQUEST['action'] === 'restore'
|| $_REQUEST['action'] === 'trash'
)
&& strpos($post->post_type, 'espresso_')
) {
return;
}
if (! function_exists('fw_set_db_post_option')) {
return;
}
$feature_image_id = get_post_thumbnail_id($post);
$feature_image_url = get_the_post_thumbnail_url($post);
//$default_options = fw()->theme->get_post_options('post');
//$post_options = fw_get_options_values_from_input($default_options);
$post_options['header_image'] = array(
'attachment_id' => $feature_image_id,
'url' => str_replace( array( 'http:', 'https:' ), '', $feature_image_url )
);
fw_set_db_post_option(
$post_id,
null,
$post_options
);
}
add_action('save_post', 'alone_theme_add_header_image_to_ee_cpts', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment