Skip to content

Commit

Permalink
Add a setting to add thumbnail to the preview #21
Browse files Browse the repository at this point in the history
  • Loading branch information
qrac committed Aug 7, 2020
1 parent 2571c03 commit 946db34
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
12 changes: 12 additions & 0 deletions functions/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ function add_theme_customizer($wp_customize) {
),
'priority' => 10
));
$wp_customize->add_setting('preview_add_thumbnail', array(
'default' => false,
'type' => 'option'
));
$wp_customize->add_control('preview_add_thumbnail', array(
'label' => 'アイキャッチをページ上部に表示',
'description' => '',
'section' => 'preview_section',
'settings' => 'preview_add_thumbnail',
'type' => 'checkbox',
'priority' => 11
));

// Custom Admin
$wp_customize->add_section('admin_section', array(
Expand Down
8 changes: 8 additions & 0 deletions page.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<?php if (have_posts()): ?>
<article class="article">
<?php while (have_posts()): the_post(); ?>
<?php
$preview_add_thumbnail = get_option('preview_add_thumbnail');
if (has_post_thumbnail() && $preview_add_thumbnail):
?>
<div class="article-thumbnail-wrap">
<?php the_post_thumbnail('large'); ?>
</div>
<?php endif; ?>
<header class="article-header">
<?php get_template_part('components/app-title'); ?>
</header>
Expand Down
8 changes: 8 additions & 0 deletions single.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<?php if (have_posts()): ?>
<article class="article">
<?php while (have_posts()): the_post(); ?>
<?php
$preview_add_thumbnail = get_option('preview_add_thumbnail');
if (has_post_thumbnail() && $preview_add_thumbnail):
?>
<div class="article-thumbnail-wrap">
<?php the_post_thumbnail('large'); ?>
</div>
<?php endif; ?>
<header class="article-header">
<?php get_template_part('components/app-title'); ?>
<p class="article-date">
Expand Down
5 changes: 2 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ a:hover {
text-decoration: none;
}

img,
iframe,
textarea {
img {
max-width: 100%;
height: auto;
}

h1,
Expand Down

0 comments on commit 946db34

Please sign in to comment.