Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active November 30, 2020 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/8cd7cbe214e3fc36cec2f17f3c931de4 to your computer and use it in GitHub Desktop.
Save Pebblo/8cd7cbe214e3fc36cec2f17f3c931de4 to your computer and use it in GitHub Desktop.
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