Extract newsletter into reusable template part and add Customizer support
This commit is contained in:
@@ -35,7 +35,7 @@ $hero_bg = get_theme_mod('hero_background_image', get_template_directory_uri() .
|
||||
while (have_posts()):
|
||||
the_post();
|
||||
?>
|
||||
<?php get_template_part('template-parts/content', 'card'); ?>
|
||||
<?php get_template_part('template-parts/content', 'card'); ?>
|
||||
<?php
|
||||
endwhile;
|
||||
|
||||
@@ -54,21 +54,7 @@ $hero_bg = get_theme_mod('hero_background_image', get_template_directory_uri() .
|
||||
</main><!-- #main -->
|
||||
</div><!-- .container -->
|
||||
|
||||
<section class="bg-primary text-white py-5 mt-5">
|
||||
<div class="container text-center py-5">
|
||||
<h3 class="display-6 fw-bold mb-4 font-serif text-white">Receive weekly insights directly in your inbox.</h3>
|
||||
<p class="lead mb-4 font-sans text-light">Join our community and get our latest thoughts sent straight to you.
|
||||
</p>
|
||||
<form class="mx-auto" style="max-width: 500px;">
|
||||
<div class="input-group input-group-lg shadow">
|
||||
<input type="email" placeholder="Your email address" class="form-control border-0 px-4" required>
|
||||
<button type="submit" class="btn btn-secondary px-5 border-0 fw-bold text-uppercase h-100">
|
||||
Subscribe
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<?php get_template_part('template-parts/newsletter'); ?>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
|
||||
@@ -114,6 +114,45 @@ function wisdom1_customize_register($wp_customize)
|
||||
'section' => 'wisdom1_hero_section',
|
||||
'settings' => 'hero_background_image',
|
||||
)));
|
||||
|
||||
// Add Newsletter Section
|
||||
$wp_customize->add_section('wisdom1_newsletter_section', array(
|
||||
'title' => __('Newsletter Section', 'wisdom1'),
|
||||
'priority' => 35,
|
||||
));
|
||||
|
||||
// Newsletter Headline
|
||||
$wp_customize->add_setting('newsletter_headline', array(
|
||||
'default' => 'Receive weekly insights directly in your inbox.',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
));
|
||||
$wp_customize->add_control('newsletter_headline', array(
|
||||
'label' => __('Headline', 'wisdom1'),
|
||||
'section' => 'wisdom1_newsletter_section',
|
||||
'type' => 'text',
|
||||
));
|
||||
|
||||
// Newsletter Subheadline
|
||||
$wp_customize->add_setting('newsletter_subheadline', array(
|
||||
'default' => 'Join our community and get our latest thoughts sent straight to you.',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
));
|
||||
$wp_customize->add_control('newsletter_subheadline', array(
|
||||
'label' => __('Subheadline', 'wisdom1'),
|
||||
'section' => 'wisdom1_newsletter_section',
|
||||
'type' => 'textarea',
|
||||
));
|
||||
|
||||
// Newsletter Button Text
|
||||
$wp_customize->add_setting('newsletter_button_text', array(
|
||||
'default' => 'Subscribe',
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
));
|
||||
$wp_customize->add_control('newsletter_button_text', array(
|
||||
'label' => __('Button Text', 'wisdom1'),
|
||||
'section' => 'wisdom1_newsletter_section',
|
||||
'type' => 'text',
|
||||
));
|
||||
}
|
||||
add_action('customize_register', 'wisdom1_customize_register');
|
||||
|
||||
|
||||
@@ -111,5 +111,7 @@ get_header(); ?>
|
||||
<?php endwhile; // End of the loop. ?>
|
||||
</main><!-- #main -->
|
||||
|
||||
<?php get_template_part('template-parts/newsletter'); ?>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
|
||||
18
template-parts/newsletter.php
Normal file
18
template-parts/newsletter.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<section class="bg-primary text-white py-5 mt-5">
|
||||
<div class="container text-center py-5">
|
||||
<h3 class="display-6 fw-bold mb-4 font-serif text-white">
|
||||
<?php echo esc_html(get_theme_mod('newsletter_headline', 'Receive weekly insights directly in your inbox.')); ?>
|
||||
</h3>
|
||||
<p class="lead mb-4 font-sans text-light">
|
||||
<?php echo esc_html(get_theme_mod('newsletter_subheadline', 'Join our community and get our latest thoughts sent straight to you.')); ?>
|
||||
</p>
|
||||
<form class="mx-auto" style="max-width: 500px;">
|
||||
<div class="input-group input-group-lg shadow">
|
||||
<input type="email" placeholder="Your email address" class="form-control border-0 px-4" required>
|
||||
<button type="submit" class="btn btn-secondary px-5 border-0 fw-bold text-uppercase h-100">
|
||||
<?php echo esc_html(get_theme_mod('newsletter_button_text', 'Subscribe')); ?>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
Reference in New Issue
Block a user