Last active
November 30, 2020 12:12
-
-
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.
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 // 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