Email Subscription Form without Plugin

Recently someone asked me which plugin is the best for email subscription form popups. First of all WordPress already has things for that and secondly I don’t like those boxes. Anyway here is a solution that is already given in the WordPress Core. Read the more up to date and famous one afterwards!
Everything cool and wrong about upcoming WordPress 4.7
Open in new tab for later

ThickBox needs no plugin

A few days ago I found ThickBox in the WordPress Core which is great for modals (click the link to see some examples). It comes along with WordPress so everyone has it and you might have seen it in the admin area, for example while uploading or editing pictures.

The pictures shows a modal which is often used in the backend.
This is how the ThickBox is used in the backend.

It is a modal which shows relevant information in a separate “window”. As you can see in the screenshot it can have some nice little control elements in the upper right corner. But for the email subscription form we only need the closing button.

Mail subscription form popup via ThickBox

Ask your service contractor or write a shortcode by yourself with the simple lines below. This is a simple example how to create a modal with ThickBox in WordPress. Just click the link below. You may like to change the style a bit 😉

Source code

Try the subscribe thickbox by clicking here.

<!-- Just let WP add the thickbox - very easy isn't it? --//>-->
<?php add_thickbox() ?>

<!-- The link can define the width and height too --//>-->
<p>
  <a href="#TB_inline?width=300&inlineId=thickbox-mail"
     class="thickbox">
    Try the subscribe thickbox by clicking here.
  </a>
</p>

<!-- Define what shall be shown --//>-->
<div id="thickbox-mail" style="display:none;">
  <p>
    <strong>You need this!</strong>
  </p>
  <hr>

  <p>
    This is your life now - popups survived. <br>
    But always remember: This is just a thickbox example ;)
  </p>

  <form action="">
    <label for="">
      Don't put your mail here:
      <input type="email"/>
    </label>

    <p>
      <input type="submit" value="Trap me!">
    </p>
  </form>
</div>

Use another post to keep content editable

The text for the email subscription form should be changeable in the admin area. So instead of writing it hard coded into the shortcode or widget better fetch a single post there:

<div id="tickbox-mail" style="display:none;">
  <?php

  // fetch post content somehow - here with ID 123
  echo apply_filters(
    'the_content' ,
    get_post_field( 'post_content', 123 )
  );

  ?>
</div>

With this you can still change the content by editing a single post. This makes it more usable for your customer.

Conclusion

WordPress can do email subscription form popups since version 3.5 released 2013, so you don’t really need a plugin for your customer or site. Simply write it in your own with only a few lines. It can even be maintainable by the user by using a single post. A very easy way without a heavy plugin.

Remember: Plugins cost runtime and are hard to change 😉

More examples can be found here: ThickBox &#8211; Modals for your website

Leave a Reply

Your email address will not be published. Required fields are marked *