About two weeks ago, the WordPress.com team released a wonderful new tool called the Follow Button to all theirs WordPress.com users. This button is floating in the bottom-right corner of a blogs and let readers subscribing, by email, to the blog’s publications. Each time a new blog post is published, they receive an update in their inbox. |
The idea is far from new, and may even looks like old-school. However, the implementation they did is simple, really well done and really clever. Also, the wording they used in the tool is perfect (for example, using the word Follow instead of Subscribe).
The only problem is that this wonderful new tool is only available for WordPress.com users! As you may know, this blog is using WordPress, but it is a self-hosted instance. After doing some research, I couldn’t find any plugins or methods to install it on my blog. Also, the email service under this user interface is built into WordPress.com. As last resort, I checked their Jetpack plugin, to see if it got added the Follow Button to it, but apparently they didn’t (it is probably too recent).
So, I was in a dilemma: I wanted this feature for my blog, I didn’t want to migrate everything to WordPress.com, and I didn’t had the time to write a plugin that does exactly this. So what I did is to take a few hours to hack my own Follow Button using what is already existing out there. In fact, I have been quite surprised to see how easy it turned out to be.
It as been as easy as installing the really good Subscribe2 plugin and to create the UI, from the original Follow Button using some HTML, CSS and JQuery code. After some re-wiring, I ended-up with my own self-hosted Follow Button.
This is what I want to share with you here, in this [raw]Hors Série[/raw] blog post. I am pretty sure that many self-hosted WordPress blogger will want it, so I took an additional hour to write and publish this blog post.
I did two additional “improvements” to the concept:
- I changed the icon to put some color in there. Not only to make it less dull, but also to bring a little bit mo attention to it.
- I also added a link to my RSS feed. To me, “Follow” is not just about emails, but it is also about other syndication mediums too. However, I kept the email as the first option to keep the spirit of the tool.
Finally, I didn’t want to hack any piece of code in WordPress nor in any other WordPress plugin. The only thing that we will modify is the theme, by adding some code to it. The current implementation could be improved by upgrading Subscriber2 for example, but I didn’t want people to have to do this to enable the Follow Button on their blog.
Step #1: Install Subscribe2
First thing first. The first thing you will have to do is to install the WordPress plugin that will enable your users to subscribe, and to manage their subscriptions, to your blog via emails. We are using the really good Subscribe2 WordPress Plugin that gives these features to your WordPress instance.
To install this plugin using WordPress’ automatic plugin installation system, follow these instructions. Read the plugin’s installation instruction if you want to do this the manual way:
- Log in to your WordPress blog and visit Plugins->Add New.
- Search for Subscribe2, click “Install Now” and then Activate the Plugin
- Click the “Settings” admin menu link, and select “Subscribe2”
- Configure the options to taste, including the email template and any categories which should be excluded from notification
- Click the “Tools” admin menu link, and select “Subscribers”
- Manually subscribe people as you see fit
- Create a WordPress Page to display the subscription form. When creating the page, you may click the “S2” button on the QuickBar to automatically insert the subscribe2 token. Or, if you prefer, you may manually insert the subscribe2 shortcode or token: [raw][subscribe2][/raw] or the HTML invisible Ensure the token is on a line by itself and that it has a blank line above and below. This token will automatically be replaced by dynamic subscription information and will display all forms and messages as necessary
- In the WordPress “Settings” area for Subscribe2 select the page name in the “Appearance” section that of the WordPress page created in step 7
On this blog, I called the page created at step #7: Follow. Once you are done installing the plugin, you can test it by visiting your Follow page and by entering your own email (one that is not attached to any user of your account is preferable) and by checking in your inbox if you receive a subscription notification. If you haven’t, you may want to take a look at this FAQ to debug any possible issue with your outgoing email service.
Step #2: Customize your Follow Page
This next step is optional. Since that the form generated by the Subscribe2 plugin is really minimalist, you may want to customize it a little bit, to change its design and to add some explanation in the page, to help your readers to understand what is going on. Take a look at my own Follow page to see what I did to customize that page.
Step #3: Add the Follow Button code in you theme
The third step is really what will morph the Subscribe2 plugin into the Follow Button. What we are doing here, is just to add the code, in your theme, to display the Follow Button.
The first thing you have to do, is to locate where the footer of the pages is generated in the theme. Open the theme folder of your blog: /../wordpress/wp-content/themes/mytheme/
. Then you will have to open a few files to check where the </body>
ending HTML tag is generated. The file where that code is generated really depends on how the theme got designed. You can do a search, within all the PHP files in that folder for the string “</body>
“. This should give you the answer right away. Once you located that place, you are good to continue with the following instructions.
Important note: It is possible that your Theme doesn’t use jQuery by default. If it is the case, then you have to edit the header.php
(or whatever the name of the file where the header of your blog is generated) of your theme, and add the following line in the <head>...</head>
section of the page:
[cc lang=’html4strict’ line_numbers=’true’]
[raw][/raw]
[/cc]
If you don’t have jQuery loaded, a JavaScript error will be returned, and the panel will “freeze” in the webpage. Once you make sure that jQuery was loaded, do proceed with this code:
[cc lang=’html4strict’ line_numbers=’true’]
[raw]
Or subscribe to the RSS feed by clicking on the counter:
[[ADD-YOUR-RSS-FEED-LINK-HERE]]
[/raw]
[/cc]
The only thing you have to do is to copy/paste that code above the </body>
tag. Then, do the following three modifications to properly wire it in your blog:
- At line #41, replace
[[PATH-TO-THE-FAMFAM-ICON]]
with the path of theasterisk_orange.png
icon, on your blog - At line #211, replace
[[PATH-TO-YOUR-FOLLOW-WORDPRESS-PAGE]]
by the URL of your Follow page (the one you created when you installed Subscribe2) - At line #228, replace
[[ADD-YOUR-RSS-FEED-LINK-HERE]]
by the link to your RSS feed
You can get the free asterisk_orange.png
icon image from the FamFamFam website. The only thing you have to do, is to download that image, and to put it in the folder you defined for [[PATH-TO-THE-FAMFAM-ICON]]
. However, you can use whatever image that you prefer, that may better fit the design of your blog.
Step #4: Disable it For Mobile Devices
Some mobile devices may have issues displaying this floating window. Sometimes, the window may be floating in the middle of the device’s screen without folding-back in the bottom of the page. For this reason, you may want to disable (remove) this option if the user is using a mobile device to read your blog. You can easily disable it if the web server detects that a mobile devise is requesting the webpage by adding these two blocks of code.
First, copy and paste this first block of code above the code of the Follow button (before line #1):
[cc lang=’php’ line_numbers=’true’]
[raw]
[/raw]
[/cc]
Then copy and paste this second block of code below the code of the follow button (after line #231):
[cc lang=’php’ line_numbers=’true’]
[raw]
[/raw]
[/cc]
This code come from the Detect Mobile Browser project and is the best mobile device detection code I saw so far. What this code does, is not to include the Follow Button if the device that is requesting the webpage is a mobile device. Otherwise, the Follow Button is added to the HTML page.
Step #5: Test it!
If you are reading this step #5, it means that you finished to create your own, self-hosted, Follow Button!
Congratulation!
But the last thing that remains to be done, is to test it. Once you saved your file with the code above, just refresh any page of your blog. You should see appearing the Follow button on the bottom-right corner of your blog. If you click on it, you should see the form that let your readers subscribing to the system. If you add one of your emails, and click the subscribe button, you should get redirected to the Follow page. Finally you should receive a confirmation email that ask you to confirm your subscription by clicking on a link.
If all these steps properly works, it means that you are done and ready to provide that new functionality to the readers of your blog!
Conclusion
Even if this blog post is few pages long, I hope you found it easy to install and setup. If you have any question regarding this hack, don’t hesitate to ask them down there, in the comments section of this post. I will be happy to answer all of them.
Happy Hacking!
Translations
This blog post as been translated in Federico Bozo in Spanish. Other translations will be added to this section.
Frederick Giasson
May 15, 2012 — 10:41 am
Hi Erika!
This looks like that you may have an error in the PHP code of your wordpress installation. My guess is that you may have introduced that error by performing the steps of this tutorial. If the errors reporting are disabled by your host, you may have some problem finding what the problem is (except if you are a PHP developer of course).
But I would suggest you to make sure that there is no PHP error that have been introduced when performing the steps of this tutorial.
Hope you can find that issue!
Take care,
Fred
Prasann
June 21, 2012 — 11:01 am
I updated to 3.4 and the button disappeared????
Please help
P.S. When I re-installed 3.3 it came back but as soon I again update to 3.4 it disappeared
Frederick Giasson
June 29, 2012 — 8:41 am
Hi Presann!
I haven’t updated yet, so I haven’t experienced this issue. Will have to test that once I have a couple of hour for my own. Will keep you updated.
Thanks,
Fred
Ajay
July 12, 2012 — 8:37 am
Hi,
How do I get the Resources tab? The same that is on your website here at the bottom. Is there a plugin for this?
Frederick Giasson
July 13, 2012 — 9:16 am
Hi Ajay,
This is a modification of the Follow button that we use to show a links page. You can check the source of this page to see how we did it.
Thanks,
Fred
Erwin
August 16, 2012 — 2:27 pm
Hi Fred,
Really good job on explaining the steps in detail, I had no problems following it and setting all up. I still encounter a problem though. When I subscribe with any email address, I receive the confirmation email, but then when I click on the confirmation link in the email, it takes me to my “Error 404 -Page not found” page. Do you know why this happens? I’d really appreciate any help you might have.
Thanks a lot,
Erwin
Zoe @ my own blog
October 20, 2012 — 7:50 am
Great tutorial! I’ve been looking for ways to make this possible. Thanks for the instructions.
Akshay
October 21, 2012 — 7:25 am
Thanks a lot! This was much needed.
Was great to see a well thought out and detailed description that even a novice could understand.
Will you ever get around to creating the plugin though?
Frederick Giasson
October 22, 2012 — 8:35 am
Hi!
Unfortunately I do not think so. I would be happy to link to such a plugin in the future, but I don’t have enough time to work on this considering all the work I am putting in my other projects.
Thanks,
Fred
Akshay
October 25, 2012 — 3:58 pm
Hi Frederick,
I have a small issue. The follow pop up works fine on the home page, but on single posts or pages its frozen. The blog is http://www.aglastation.com
Have a look at it whenever you have the time.
Also, I tried to replicate your resources tab but it doesn’t seem to work. I want to create one, where I can show the RSS feed from my other blog. Any pointers?
Thanks,
Akshay
Frederick Giasson
October 30, 2012 — 8:57 am
Hi Akshay!
Yeah, seems to be in conflict with other plugins in these pages (the bottom bar or something; I can see multiple JavaScript errors on your page)
Thanks,
Fred
sakthi
November 1, 2012 — 1:07 am
Hi,
Thanks for this tutorial, i did it in my site, its working in safari, mozilla etc browser but it wont working in ie browser, can you give me any solutions for this, my site is http://teotrainer.com
Thanks
Sakthi
alessandra
January 7, 2013 — 8:04 am
Hi Frederick, I have this plugin on my blog and tried to follow your instructions, since I am not a programmer, but something is not working as it should. First af all a programmer friend of mine installed me the plugin so point 1 e 2 are done. I had problems with point 3. The pages of my theme are all in php so it was impossible for me to see html code as I am use to see elsewhere. That is why I was not able to insert the code you gave us and actually I have the same problem with other stuff (analytics for example).
Infact if you see my follow page, it appears this line: You may manage your subscription options from your profile where profile is a link to the administration panel. Surely enough there is something I do not understand. Thanks for helping me!
Mella
January 12, 2013 — 12:17 pm
Hi Frederick,
I love this follow button! But I’m having a little difficulty in the setup. I get the below showing on the frontend and cant see where the code is wrong on mine. I copy and pasted your code twice to try and fix it. I’m sure its something simple but I’m not a coder…
Join get_var(“SELECT COUNT(id) FROM wp_subscribe2 WHERE active=’1′”); ?> other followers:
vicki
March 22, 2013 — 10:09 pm
Hi. I have the same widget as you do for following but mine is not displaying the numberof followers..like yours says “Join 32 other followers”.. i checked your code and mine and its identical:
but mine shows nothing reagarding the number of followers. do you have a hit a certain number of followers before it will show up? theres nothing really in my widget panel to adjust this widget…only in the plugin editor can i edit things. Any ideas?
thanks!
hassan
October 15, 2013 — 5:35 pm
Hi Fred,
i thank you for your help,i have tried your code but the windows is not completed,and when i click on follow nothing happen,
please have a look http://th3wall.com/
thank you again
regards,
hassan
October 15, 2013 — 5:39 pm
Hi Fred,
it is work when i put the jquery in the footer with you code,
thank you alot:)
linsey
October 21, 2013 — 12:35 pm
Hi Fred. I know im late to the party but I’ve just come across this post… I have just tried to install this follow button onto my site and it looks like ive failed miserably lol. I have checked the code and all seems right to me so I have no idea what ive done wrong. If you could help, that would be great as im already pulling my hair out. lol
http://www.ljsealey.com
P.S This is just great! I have wanted the same follow button as wordpress.com for a while.. so thank you :0)
Ralf
January 20, 2014 — 12:06 pm
Many thanks for this guide. I integrated it in my website and it works great.
Mark
February 20, 2014 — 1:25 am
Subscribe2 page and Subscribe2 widget successfully receive new subscribers. But subscriptions submitted using the Follow popup do not work. It shows Confirmation msg. on it’s way but no messages are received and no new user has been added to current subscriber list. Any thoughts?
aveesh Kumar
March 11, 2014 — 9:07 am
I think this functionality is already in the latest Jetpack – so you can connect your self hosted wordpress site to the follow post funcionality using a wordpress.com account for your users
Fred Jackson
March 24, 2014 — 4:00 am
Hi Fred, 😉
Love this and it appears that it will be just what I need for my blogs.
One little problem… It won’t send the email. The s2 plugin woks great but it appears that the follow button does nothing. When I click it it appears to do what it should and takes me to the Follow page showing that a confirmation email has been sent but the email never arrives in the inbox.
Thanks.
Fred
Eddie (@50minCoach)
January 7, 2015 — 9:35 am
Hi Fred,
That is a real nice tool despite I can’t use it for now. I do have some basic questions that should help in my next steps that in return should lead into me installing your follow tool.
Q1: right now my blog is 50minCoach.wordpress.com. If I upgrade my account, will I be able to install your follow tool?
Q2: I presume that “Subscribe2” can only be installed once I upgraded my wordpress account. But for the meantime, any suggestions how to use my current free account to do something similar functions?
Thanks a lot for your effort and time given.
Mon @ Blognifico
December 19, 2015 — 11:59 am
Really a great tutorial thank God i found this article online. I keep wondering where do they get this kind of follow button because i want it on my blog too.