define default featured image on page

This commit is contained in:
Jonas Heinrich 2020-06-14 14:27:48 +02:00
parent 77306b737b
commit 28be03d171
3 changed files with 21 additions and 2 deletions

View file

@ -139,6 +139,8 @@ get_header();
<figure class="teaser-box-image">
<?php if ( has_post_thumbnail() ) { ?>
<img src="<?php echo get_the_post_thumbnail_url(); ?>">
<?php } else { ?>
<img src="<?php echo esc_url( get_option( 'kit_defaultimage' ) ); ?>">
<?php } ?>
</figure>
</a>

View file

@ -52,6 +52,8 @@ get_header();
<figure class="teaser-box-image">
<?php if ( has_post_thumbnail() ) { ?>
<img src="<?php echo get_the_post_thumbnail_url(); ?>">
<?php } else { ?>
<img src="<?php echo esc_url( get_option( 'kit_defaultimage' ) ); ?>">
<?php } ?>
</figure>
</a>

View file

@ -194,6 +194,21 @@ function theme_customize_register( $wp_customize ) {
)
) );
$wp_customize->add_setting( 'kit_defaultimage', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options'
),
);
$wp_customize->add_control( new WP_Customize_Image_Control(
$wp_customize, 'kit_defaultimage_control', array(
'label' => __( 'Default featured image', 'kit' ),
'settings' => 'kit_defaultimage',
'section' => 'title_tagline',
)
) );
}
add_action( 'customize_register', 'theme_customize_register' );