enewsletter placeholder

Hi,
I placed the enewsletter signup widget in the footer of my site and another one in a bar using the do_shortcode() function. They both work fine.
I wanted to add a placeholder to the email field of both of them, I read the instructions of this post (link) but the placeholder is shown only in one of the two email field.
and used this code

function wpmu_enewsletter_form_placeholder() {
    ?>
    <script type="text/javascript">
    jQuery(function($) {
         $('#e_newsletter_email').attr("placeholder", "Your email address");
    });
    </script>
    <?php
}
add_action('wp_footer', 'wpmu_enewsletter_form_placeholder');

How can I do to have both field with the placeholder? thank you

  • Denitsa
    • WordPress Warrior

    Hello peter_harris,
    I hope you're doing great today and thanks for your question!

    The reason you're not getting a second placeholder is that your code adds the action hook to the wp_footer section only. You need to have one added to your bar also in order for the placeholder to show up there.

    If you're using a shortcode you might want to take a look at the add_shortcode() function reference: https://codex.wordpress.org/Function_Reference/add_shortcode

    If this doesn't make sense, could you perhaps grant support access from the dashboard plugin so we can take a closer look and suggest the right piece of coding?
    This could be done via Dashboard - WPMU DEV -> Support -> Support Access -> Grant Access or by following this guide here:
    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Looking forward to hearing from you!

    All the best,
    Denitsa

  • peter_harris
    • Syntax Hero

    Hi, everything's fine here thank you. I hope you're fine too :slight_smile:

    <div id="barra" align="center">
    <div id="text_bar">Never miss a story from the Blue Skeleton </div>
    <div id="subscribe"><?php echo do_shortcode("[enewsletter_subscribe]"); ?></div>
    </div>

    At the very end of the single.php file (the template of the single blog post - the bar should only be visible on blog posts).

  • Nithin
    • Support Wizard

    Hi peter_harris,

    Hope you are doing good today. :slight_smile:

    I have changed the position of your div, ie the following code in your single.php file:

    <?php get_footer(); ?>
    <div id="barra" align="center"><div id="text_bar">Never miss a story from the Blue Skeleton </div><div id="subscribe"><?php echo do_shortcode("[enewsletter_subscribe]"); ?></div></div>

    Is replaced with the following one:

    <div id="barra" align="center"><div id="text_bar">Never miss a story from the Blue Skeleton </div><div id="subscribe"><?php echo do_shortcode("[enewsletter_subscribe]"); ?></div></div>
    
    <?php get_footer(); ?>

    Once done, please replace the above jQuery that you have provided, with the following one:

    function wpmu_enewsletter_form_placeholder_two() {
        ?>
        <script type="text/javascript">
        jQuery(function($) {
             $('#barra #e_newsletter_email').attr("placeholder", "Your email");
               $('#e_newsletter_subscribe-2 #e_newsletter_email').attr("placeholder", "Your email");
        });
        </script>
        <?php
    }
    add_action('wp_footer', 'wpmu_enewsletter_form_placeholder_two');

    Please let us know how that goes, have a nice day. :slight_smile:

    Kind Regards,
    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.