Esempio n. 1
0
/**
 * [get_wpfeatured_image_url_with_default description]
 *
 * @see http://stackoverflow.com/questions/6384431/creating-anonymous-objects-in-php
 * @see https://wordpress.org/support/topic/getting-a-post-featured-image-url
 * @see https://wordpress.org/support/topic/retrieveing-featured-image-url
 * @see http://stackoverflow.com/questions/11261883/how-to-get-wordpress-post-featured-image-url
 * 
 * @param  [type] $post_id [description]
 * @return [type]          [description]
 */
function get_wpfeatured_image_url_with_default($post_id = 0)
{
    $wpfeatured_image_url = get_wpfeatured_image_url($post_id);
    if (is_null_or_empty_string($wpfeatured_image_url)) {
        $wpfeatured_image_url = get_default_featured_image_url();
    }
    return $wpfeatured_image_url;
}
Esempio n. 2
0
<?php

/* need to improve */
$banner_url = '';
$custom_css = '';
// home only
$title = '';
$subtitle = '';
$home_url = '';
if (is_home()) {
    $title = get_bloginfo('name');
    $subtitle = get_bloginfo('description');
    $home_url = esc_url(home_url('/'));
} else {
    $post_id = get_the_ID();
    $banner_url = get_wpfeatured_image_url($post_id);
    if (is_null_or_empty_string($banner_url)) {
        $banner_url = get_default_banner_url();
        $custom_css = 'default';
    }
}
?>

<header class="banner <?php 
echo $custom_css;
?>
"
  <?php 
the_background_image_style($banner_url);
?>
>