How To Build Rotating Subscription Forms
Supposing you have a couple of different email lists that you want to rotate out by the month, week or year. It would be rather tiresome to have to manually change it out each time. While you can hire these out, it’s more economical in the long run to let technology do it. Especially when these are the perfect things to be automated.
How do you get it done? That largely depends on what you are using to publish your website. Since I am a WordPress fan, the following instructions are MFWP (made for WordPress) 🙂
Functions.php
First of all, to clear up confusion and followup questions. Everything we are doing will go into your theme’s functions.php file. If you switch themes, you will lose this feature, but don’t worry. You can easily copy and paste the code over to your new theme’s functions.php.
Determine Your Times
In a real scenario, you would already know how often you’d like to rotate or switch out your forms. Everything in this tutorial is dependent on this. The easiest is to go by hard dates and because of that and for brevity’s sake, we are going to develop this based on month.
Paste This Code
Copy and paste this code into your functions.php file
https://gist.github.com/lynettechandler/31bfc7e3eafe10cde20a
Replace Your Form Code
Now comes the hard work. Paste your different subscription form codes for each month in the spot where it says “Paste form code here“. Notice at the end, there is a default option. I suggest you enter a form that you want to use if you don’t know what the month is. This is unlikely to happen but it’s always a good thing to have a fallback incase of hiccups.
Add Your Shortcode
Now, where you want the subscription form to appear, simply enter this shortcode [rotatingforms]. Now, each month that passes by, the form will be rotated out automatically and perpetually. Neat huh?
Here’s something to think about. Just because this is written for a subscription form doesn’t mean you have to enter a form. As you can see I have a header with month names for each month. You can actually enter any HTML code in between the <?php and ?> tags. That should give you some ideas how to re-use this code and if you find some creative uses, let me know I’d love to hear about it.
FYI, this code is written and tested in WordPress 3.6.
Do You Want A Hands-Free Business?
Then get this guide to help you systemize your business so you'll have more time working on your business.
Hey! I want to make sure you know what you're getting here. In addition to the guide, you will also receive our memo that includes special offers, announcements and of course actionable information.
This is cool! So if you used day instead of month and d instead of m then had 31 spots, you could rotate testimonials or featured clients or something like that by what day it is right? Might have to try that!
Glennette Goodbread, Owner
Premium Web Design and Hosting
premiumweb Yes Glennette. You can absolutely do that. Good thinking!
Awesome post!! LOVE THIS for end of post sign up boxes and/or promos that we’d like to change frequently without having to manually input them each time we do a post. Thanks!!!
If we’re using it for days and wanted to do one form on odd days and one on even days could we input only 2 cases and list them like this
case ‘01,03,05’
case’02,04,06′
or would we need to do all 31 days on their own line?
@Arika I would enter it as
case ’01’:
case ’03’:
case ’05’: