Skip to content

Instantly share code, notes, and snippets.

Created February 28, 2018 05:08
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 anonymous/dc2e73619fcd3be245aeeea78d3a387d to your computer and use it in GitHub Desktop.
Save anonymous/dc2e73619fcd3be245aeeea78d3a387d to your computer and use it in GitHub Desktop.
/**
* [travel_log_child_get_trip_single_banner_image Add Banner Image to Trip single]
* @return void
*/
function travel_log_child_get_trip_single_banner_image(){
if ( defined( 'WP_TRAVEL_POST_TYPE' ) ) {
if ( is_singular( $post_types = WP_TRAVEL_POST_TYPE ) ) {
$bg_image = '';
if ( function_exists( 'wp_travel_get_post_thumbnail_url' ) ) {
$bg_image = wp_travel_get_post_thumbnail_url( get_queried_object_id(), 'large' );
?>
<style>
.custom-header {
background-image: url('<?php echo esc_url( $bg_image ) ?>');
background-size: cover;
}
</style>
<?php
}
}
}
}
add_action( 'wp_head', 'travel_log_child_get_trip_single_banner_image' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment