How to Add an Opt-In Box Below Your Posts in WordPress

Yes please! Sign me up!
Hey there, Ashley! Question for you – how would one put a subscription box below one’s posts in WordPress like what you have on Nose Graze? Is there a plugin or something to install? Thanks! πŸ™‚

Hi there! πŸ™‚ Adding an opt-in form below your posts is an excellent idea. I’m in the process of compiling statistics that compares the signup rate for my sidebar form versus the signup rate for my form below the posts, but so far it’s neck and neck. At the very least, my data shows that people do use my below post opt-in regularly, so that means it’s worth having!

I coded mine in manually

My opt-in form isn’t part of a plugin; it’s something that I coded into my custom theme. But that doesn’t mean it’s not possible for you to implement this, it just means you have to find another way.

Using Tweak Me v2?

Tweak Me v2 WordPress theme

If you’re using the Tweak Me v2 theme, then you’re in luck! It’s super easy to add an opt-in form to your theme. Tweak Me v2 comes with a “below posts” hook. If you navigate to Appearance » Theme Options and click on the “Hooks” tab. That’s where you’ll find a bunch of different text boxes you can use to insert content in specific areas. And one of those boxes is “Below Posts Hook”. That’s where you can place your email opt-in form code!

For more specific instructions, read the Tweak Me v2 documentation on adding an opt-in form. Here’s an example of what it looks like when you’re done:

A form to subscribe to a blog through email

Using a different theme? Try a plugin!

The beauty of WordPress is that there’s a plugin for everything, including opt-in boxes like this! Here are a few plugins you can try out:

Or, you can code it yourself.

If you want to code this directly into your theme, it’s pretty easy! You can add this code into your theme’s functions.php file:

function add_my_optin( $content ) {
	$post_type = get_post_type();
	
	// Return the unfiltered content if we're not on a post.
	if ( $post_type != 'post' ) {
		return $content;
	}

	// If we're not on a single post page, bail.
	// You can remove this if you want the form to appear on your homepage too.
	if ( ! is_single() ) {
		return $content;
	}
	
	ob_start();
	?>
	
	<!-- Add your opt-in form code here! Example: -->
	<form>
		<input type="text" name="email" placeholder="Enter your email">
		<input type="submit" name="submit" value="Subscribe">
	</form>
	
	<?php
	// Add the opt-in form after the post content.
	return $content . ob_get_clean();
}
add_filter( 'the_content', 'add_my_optin', 125 );

What kind of opt-in form do you use?

When subscribing to a blog, have you ever used an opt-in box that was below the post?

Photo of Ashley
I'm a 28 year old California girl living in England (I fell in love with a Brit!). My three great passions are: books, coding, and fitness. more »

Don't miss my next post!

Sign up to get my blog posts sent directly to your inbox (plus exclusive store discounts!).

You might like these

Leave a Reply to Bieke @ Istyria book blog Cancel reply

(Enter your URL then click here to include a link to one of your blog posts.)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

40 comments

  1. I haven’t added an opt in form on my site yet. I’v read a lot recently about the value of building an email list. I guess that is something I should really focus on. Thanks for adding a couple of ways for those of us who don’t really write code to add an opt in. Those will be really helpful.

    Adam recently posted: Hydrogen Powered Fuel Cell Car
    1. You definitely should! Especially if you have a blog. If you don’t have an option to subscribe via email, you’re cutting out a huge chunk of potential followers. There are some people (like me) who ONLY follow via email.

  2. Oo thanks so much for great blogging advice as usual Ashley! I downloaded Optin forms and it was really easy to set up! The one thing is that I can’t edit the email link now that I’ve added it and I’m not sure I put the right thing in for Mail Chimp, sigh. It leads them to the Mail Chimp sign up page though so it isn’t horrible, ha.

    Anya recently posted: When Life Gets Hard
    1. Chloe doesn’t have a built in option for that, so I suggest you look at the plugins I recommended for use with other themes. πŸ™‚

  3. Okay. I’m already using a plugin that meshes with MailPoet, and liked the demo for those newsletters since they’re all in Wp vs on an external site, and it doesn’t look like the other two have that service, hence my question. I suppose I could switch plugins if necessary, though. I really want that sign up form at the bottom of my posts! πŸ˜›

    1. It’s still possible to insert a form like that with MailPoet, it would just require custom coding—possibly a custom plugin.

        1. And just to clarify, if they do have a shortcode then I could create this for you, but it isn’t included for free as a customer. It’s something I’d have to charge to create. πŸ™‚

              1. Will do! It may be a while; I’m desperately trying to just get my darn blogs functional as I’m now past my deadline for relaunch. Stuff just won’t stop coming up. #annoyed I’m aiming for pretty and functional at the moment; once I’m back online and moving, and have a budge, I’ll be in touch with a few questions. Thanks! β™₯

                Alena Belleque recently posted: What I Read #3 – Fall 2014
  4. Hi Ashley! Thank you so much for all your incredible tips!
    I am building my portfolio/blog since I am an advertising/pr & graphic design major, I am a little concerned because I posted the code:

    function add_my_optin( $content ) {
    $post_type = get_post_type();

    // Return the unfiltered content if we’re not on a post.
    if ( $post_type != ‘post’ ) {
    return $content;
    }

    ob_start();
    ?>

    <?php
    // Add the opt-in form after the post content.
    return $content . ob_get_clean();
    }
    add_filter( 'the_content', 'add_my_optin', 125 );

    And now my website is missing! πŸ™
    Did I mess up? What did I do? I can't even access the wp-admin site…

    1. Either you have invalid characters in your code or you pasted it in the wrong place. πŸ™ Pasting PHP code in the wrong place can result in a syntax error on your site. It’s easily fixed—you just have to remove the code you added via FTP or your host’s file manager.

    1. It’s not listed as one of their supported services. Here’s the list from the plugins page:

      AWeber
      iContact
      MailChimp
      GetResponse
      MadMimi
      Interspire Email Marketer

  5. Hi Ashley,
    This is brilliant and really helpful. One question though, is there a way to only show it on the blog itself? At the moment, the optin is showing at the bottom of each blog item on the main blog page (see here for an example on the testing site: http://astro-shrink.thedesignpeople.com.au/blog/ ). I really only want it to show at the bottom of the actual blog article page (eg like here: http://astro-shrink.thedesignpeople.com.au/capricorn-high-achiever-procrastinator/ )
    Thanks for your help!

    1. Hi Nic,

      I added a new piece to the code if you want to take a look and add that in. Look for this new section I added:

      // If we're not on a single post page, bail.
      // You can remove this if you want the form to appear on your homepage too.
      if ( ! is_single() ) {
      	return $content;
      }

Recent Posts

    Random Posts