Display a Subscription Form in the Sidebar

Add a subscription form to the sidebar.

<?php
function display_subscription_form() {
    ?>
    <div class="subscription-form">
        <h3>Subscribe to Our Newsletter</h3>
        <form action="https://yournewsletterprovider.com/subscribe" method="post">
            <input type="email" name="email" placeholder="Enter your email" required>
            <input type="submit" value="Subscribe">
        </form>
    </div>
    <?php
}
add_action('widgets_init', function() {
    register_sidebar(array(
        'name'          => 'Subscription Widget Area',
        'id'            => 'subscription_widget_area',
        'before_widget' => '<div class="subscription-widget">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2>',
        'after_title'   => '</h2>',
    ));
});

Post Comment