Hide Number of Comments if None in WordPress

Just a quick one to tidy up your blog a little and make it a little less negative! It’s quite common to see a list of posts on a WordPress blog with meta info underneath each one displaying things like Post Time, Post Category, Author and the number of Comments the article has. For smaller blogs, there probably wont be too many comments left so you’ll see “No Comments” or “0 Comments” under a lot of the posts. I’ve always thought this looked a little sad on my own blog. Like, here I am slaving away on these excellent and informative articles and no one is reading or commenting on them!? Here’s a quick code edit to hide the “No Comments” text if there are none but show the number of comments and link to them if there are any.

Open the index.php file for your theme in a HTML editor and look for a line similar to this:

<?php comments_popup_link(‘0 Comments’, ‘1 Comment’, ‘% Comments ‘); ?>

Change this to:

<?php comments_popup_link(”, ‘1 Comment’, ‘% Comments ‘); ?>

You’re just deleting any text that should be displayed when there are no comments so if there are none, then nothing will be shown. Geddit!?

You might need to edit this line in several other template files also such as Archive.php, Category.php, Search.php, Tag.php and anywhere else comment numbers are displayed.

Leon.

Add a Contact Form to Facebook

I bet you’re like me and thought this should have been fairly easy right!? Wrong. Unless I missed something fairly obvious, there doesn’t seem to be an easy way to do it without the help of either a web developer/FBML expert or external apps/sites. The first obvious thing I tried was searching for Facebook Form apps but nothing turned up. Secondly, I tried pasting some of the code from my own site forms including offsite code from my Blog Newsletter (which normally works anywhere) into an FBML app tab and presumably due to FBML or Facebook restrictions, that was rendered useless.

Facebook Contact Form

After some Google research, I came upon an excellent and mostly free form building site called JotForm.com which presents you with an easy to use WYSIWYG form builder with all the options you could ever need. The most important option I found at the end was that you can generate Facebook specific FBML code that is guaranteed to work in your FBML app tab. Jotform doesn’t stick it’s logos all over your form, in fact, there’s no clue it’s there at all through the whole process. It also redirects any data entered to an email address of your choice.

I tried it and here are the results after very little time messing around:

www.facebook.com/ReverbStudiosDesign?v=app_4949752878

Batch Upload to Dropbox via WordPress

I’m currently building a site for a local Pharmacy who would like to have the ability to allow customers to upload photos to be developed via an online form on their site. The catch is, they would prefer to have the files go to their Dropbox (File sharing/storage site) folder for easy processing. I done some searching for an off the shelf WordPress plugin and this one came closest but unfortunately, didn’t have batch capability and seems slightly buggy – WordPress.org/extend/plugins/dropbox-plugin.

I then got to wondering if it was possible to Email pics to Dropbox and found a few sites/apps that can do it well. This one seemed best – SendToDropbox.com.

So, armed with the above knowledge, here’s what I done:

Contact Form 7

This is one of the most popular FREE form plugins for wordpress and the current version includes the ability to add File Upload fields to a form. As many as you want. I setup a new form with standard questions like Name, Email, etc..and included a few upload file fields with specifications as to File Type, File Size, etc.. I then pasted in the automatically generated email address from SendToDropbox.com in the “To” field. Contact Form 7 also has the option to send the results of the form submission to a second email address and I setup a duplicate of the first email to go to the proper contact email address of the website, minus the file attachments, just so the website admin would get notification of newly uploaded files. Of course, the Dropbox PC software also alerts you straight away when new files are added to your folder. See below for Contact Form 7 settings:

Contact Form 7

SendToDropBox.com

This is a simple but cool site that connects to your Dropbox account and provides a custom email address that you can send emails and file attachments to. It also has a copule of extra features that process emails received such as: Automatic Unzipping, Email Content Inclusion and control over Dropbox Folder Names/Trees for emailed files, ie – files uploaded in this way can be added to folders named by Date, Email Address, Subject, etc..handy for keeping thigs organised and finding customers uploaded files! See below:

Send To Dropbox

Result

The end result is a normal looking contact form on the customers site that allows basic personal info to be uploaded to Dropbox along with files and photos. The website admin gets instant notification of new files added to his Dropbox account as well as email notifaction of the customer’s details. Nice!

Of course, it can be even simpler. If you just add an email address to the site like Upload@SiteName.com and have that forward on to the custom SendToDropbox email address then people can use the methods they already know for sending emails and attaching files and it will work just as good. I personally think it’s best and more professional to use the form method but perhaps a choice can be given.

Leon.

My Social Media Routes

I’m not sure I’m doing a great job lately answering the often asked question of how exactly to go about EASILY ‘publishing’ content on Social Media Networks so I’ve decided to try to visualise here how I personally do it and make it easier for others as well as myself to understand!

Essentialy I have 2 main sources of content, this Blog and Twitter. It’s rare that I would post content directly in any other network. From my blog, posts go out to all the other networks and indeed Twitter but I also microblog from Twitter directly. Doing things this way, ie – only creating content in 1 or 2 places max but routing that content to multiple different places, is a fantastic and efficient method of having an active precence on the main social networking sites without the hassle of manually going in and creating content on them all individually.

I find using Dlvr.it a great help in routing my content but it relies on your main source having an RSS feed.

I believe these methods or routes are fairly common for most active networkers right now:

Social Media Routes

Mobile Detection & Optimization

As a kind of follow on from a recent article of mine re Optimising your Website for iPhone viewing, I’d like to expand on a few points and talk about general optimisation for Mobile phones and how to detect which Browser or User Agent your site visitors might be using.

I’ve recently added some detection code to my main (Non WordPress) site that basically looks to see which user agent or mobile phone platform my visitors are using and if it’s a non-iPhone phone then they get redirected to my other site ReverbStudios.Mobi, a site I built specifically to render fast and well on most mobile browsers. If they are not on a phone and at a normal PC or Mac then they just get to see the main site ReverbStudios.ie

Mobile Phone

As far as building an optimised site for mobiles is concerned, here’s my best advice:

  • Have very few, if any, Images and Scripts,
  • Make any images you really do need to use smaller than 200px wide max,
  • Specify the dimensions of all images used,
  • Only include basic content such as an outline of services and contact details,
  • Use “Callto:” links on any phone numbers you include so people can click the number to initiate a call,
  • Add links to your main site or social networking precences for users with smartphones.

I use the  WP-Touch plugin for my WordPress blog to allow Smartphone users to choose either a normal view of the site or a simplified version. The plugin handles detection and design.

Here’s the code I’ve used on my main, static site to detect people’s browsers, it’s courtesy of Richard Shepherd but with a few changes with help from Justin Knecht.

Mobile Detection.txt

Identifying WordPress Spam Comments

WordPress users will know that there’s a default spam plugin called Akismet included that is fairly effective for automatically identifying and dealing with spam. If you’ve got comments turned on for your blog posts or pages then you’ll occasionaly get email notification of new comments which you must either Approve, Mark as spam or Trash and links will be provided in the email for each option.

There’s a new breed of spam that escapes filters like Akismet and appears to be a bit more real than traditional spam, ie – no mention of viagra or no funny email or web addresses with foreign lettering. They look and read like a manually created comment by a real person and probably are actually created in this way. Typically they take the form of complimentary comments about your content. Here’s one I got today for example:

“I loved this post. Very informative.”

The commenter added this web address – http://articledominance.com/freereport.html which appears to be a get rich quick offer/site asking for your email address and name, possibly to spam you some more!

My basic, common sense advice when you get comment notifications from your blog is to have a quick look at the commenter’s url/website and see if it looks legit. Also see if the commenter’s text is generic or actually relates specifically to something you’ve said in your post. As another general rule of thumb, if the comment doesn’t contribute anything interesting, related or useful to the discussion on your article then I’d delete it.

Here’s a few things, specifically to do with the commenter’s website that I would delete or mark a comment as spam for:

  • Overselling something,
  • Get rich quick content,
  • Asking for signups/email addresses,
  • Advert heavy sites,
  • Sites with tons of Google adverts,
  • Completely unrelated site.

Leon.

iPhone OS 4.0 Quick Tips

I downloaded the new operating system (OS 4.0) upgrade for my iPhone last night and it went fairly smoothly. I was eager to try out some of the fantastic new features outlined including: Multitasking, Folders, Camera Zoom and Orientation Lock. Post upgrade, the new Home Screen Wallpaper feature was immediately visible as was the new iPad style reflective footer shelf for the default apps. It wasn’t immediately obvious how to use some of the new features so here’s how for those of you wondering:

Multitasking/Orientation Lock:

To acces the Multitasking screen just press the Home button twice. This brings up a bar at the bottom of the screen which lists your currently running apps. If you swipe all the way to the left you’ll see some cool new iPod controls and the button for locking the screen in either Portrait or Landscape mode. A very handy feature that will prevent unwanted rotations in bed!

Orientation Lock/Multitasking

Folders:

To create new folders, simply hold down on any app to enter the edit screen and drag an app on top of another one to create a new folder pair. You can then name this new folder and drag more apps into it.

Folders

Digital Zoom:

I know digital zoom is kinda silly and low quality but it might come in handy the odd time. To access the new zoom features, tap just above the Take Snapshot button and you’ll see the zoom slider appear.

Digital Zoom

Hope this helps.

Leon.

Speed Up Your Website for Google

Since Google and other search engines take the size and download speed (among many other factors) of your site into account when deciding where to rank you in results, it makes sense to make sure it’s fast! It will also give your impatient visitors a much better experience. Here’s a few things you should consider doing:

  • Make sure your hsoting server is decent/fast.
  • Build your site with CSS/DIV’s rather than with Tables.
  • Be efficient, tidy and semantic with your HTML and CSS code.
  • Validate your code.
  • Compress all images as much as possible.
  • Avoid Flash/Video/Audio files embedded on the home page.
  • Don’t use to0 many unnecessary fancy scripts or widgets just to show off, eg – Facebook, Live Chat, Google Gadgets, etc…
  • Merge your external CSS files into one (the less external file calling the better).
  • Merge your scripts files into one (as above).
  • Place script calls at the footer of your page so they load last – WordPress Plugin.

Compressing via Gzip:

I’ve just done this belatedly for both my main static site and my WordPress blog. To turn on Gzip for a static PHP page for example, I’ve used this code:

<?php if (substr_count($_SERVER[‘HTTP_ACCEPT_ENCODING’], ‘gzip’)) ob_start(“ob_gzhandler”); else ob_start(); ?>

Your server and the visitors browser both need to support compression for the above command to work. Test whether your site is compressed or not here:

www.gidnetwork.com/tools/gzip-test.php

For my wordpress blog I’ve used the WP HTTP Compression plugin. There are a few excellent Caching plugins for WordPress such as WP Super Cache and W3 Total Cache which both handle compression too but I found both of them a bit over the top and they played havoc with my auto publishing to Twitter and Facebook.

Try this website page speed tester to see where you’re at now!

www.iwebtool.com/speed_test

Leon.

Using Facebook Ads

I’m focusing on the Facebook Advertising system for this article mainly because I’ve tried a lot of others from Google AdWords, to Linkedin Ads to Banner advertising to Offline, etc.. and I just find the Facebook system to be the simplest and potentially most effective given the number of people using Facebook regularly these days (about 1.5 million in Ireland alone).

To create an ad in Facebook, login and click “Ads & Pages” in the left menu of the home page.

Create an Ad:

Click “Create an Advert” top right and you’re presented with a simple form/wizard to guide you through the process. You will have a choice of creating an ad from scratch or ‘advertising something you already have on Facebook’ like a Business Page. For a new advert you are asked for a Destination URL, Ad Title, Body Text and Image and as you type you see how the ad will look to others on the right hand side.

Design your Ad:

Be creative with your ad text, title and image, after all you need to catch people’s attention! Facebook doesn’t allow too many capitals or symbols so just say something interesting. The Destination URL is important in that it is where ad viewers will end up after clicking your ad. You need to make sure this page relates to what you have said in the advert and is easy to read and navigate with perhaps a large ‘call to action‘ button or link to get people to buy your product/service or just contact you.

Targeting options:

This is where Facebook advertising is really interesting for me. You can set the ad up to only show to Facebook users in a certain country or even city or group of countries/cities. You can also target people by Age, Gender, Relationship Status, Birthday, Language, Likes & Interests, Education level, Facebook Friends, Fans of a Page/Event/Group, etc.. The cool thig is that as you make these selections, Facebook tells you exactly how many people you are targetting based on your choices so you get to see your ad reach as you go!

Spend:

Finally, choose your ad duration and max daily spend to avoid getting an unexpectedly high bill and choose a cost per click that gives you a realistic chance of your ad being pushed to the top and actually seen. You will be asked whether you want to pay for Impressions or Clicks. I’ve never understood why anyone would want to pay just for the ad to be shown when there’s no guarantee people wil actually look at it. Better instead to just pay for actual clicks surely!?

Analytics:

One of the main benefits in using online advertising channels like Facebook over traditional methods like print and other media is that you will have access to detailed statistics on the performance of your ad. Everything from the number of times your ad was shown to how many times it was clicked on to average cost per click and total spend is available so you can evaluate how effective the campaign was.

Just remember to ask inquirers where they heard about you!

Leon.