When Free Themes (and Plugins) Are Better Then Premium Paid

If you are here looking for advice on whether to use a free theme, or to pay for a premium one, then I strongly recommend that you use the free wordpress.org themes.

Having said that, here are some other general points about your choice, and this post:

  • From now on, when I write ‘theme’, then I also mean ‘plugin’.
  • Never get your free themes from anywhere but http://wordpress.org/themes
  • Never pay for a premium theme without a recommendation from someone you know personally or professionally.
  • Always use a test installation of WordPress to trial run your theme

The best things about free themes

The worst thing about paid themes

  • They don’t have to stand up to any coding standards.
  • You are not guaranteed any support, let alone any more than you get in the wordpress.org forums
  • They prey on your lack of WordPress knowledge, making you think you’re getting something better. Because you haven’t picked a free theme!

So, now that I’ve hopefully frightened you a little bit away from premium themes, I’m going to immediately back-track a little. There are premium themes that are worth paying for. However, if you are here, trying to work out which ones they are, then you don’t have the experience to judge this for yourself. Your path will be one of pot luck.

When should you buy a premium theme?

Some of these points will overlap, but I’m including them all to try to help you get an idea of what to look for when you’re really adamant that a pre-built premium theme is your only solution.

  • When someone you know and trust recommends it.
  • When someone you have an established business relationship with recommends it
  • When a WordPress professional recommends it
  • When you have money to burn and aren’t particularly worried about whether your site actually works or is secure

The most common scenario is you’ve decided that your business is worth investing your hard-earned money in, you’ve realised that $25 is not going to get some magical theme that will propel your site into the FTSE500, and you want someone professional applying their skills. And so you hire a freelancer, and they recommend purchasing a framework, or parent theme.

The Framework Theme and The Freelancer

Freelancers commonly have a framework theme that they are intimately familiar with. It is a premium theme packed fill of functionality and options. They then take your vision and make a child theme, building your desired design whilst harnessing all the functionality.

Setting different static WordPress home pages for different themes

You can get WordPress to use a different theme to different visitors to your site. For example, serving up a mobile theme for visitors using a phone. Well, perhaps you want to alter some of the WordPress settings too, like displaying an alternative homepage.

Here’s a bit of code that shows either your blog posts, or a specific static home page depending on which theme is active.

global $static_theme_name;
$static_theme_name = 'Twenty Twelve';
add_filter( 'pre_option_show_on_front', 'tcb_pre_option_show_on_front' );
function tcb_pre_option_show_on_front( $false ){
  global $static_theme_name;
  $theme = wp_get_theme();
  if( $theme->name == $static_theme_name ):
    return 'page';

  return 'posts';

add_filter( 'pre_option_page_on_front', 'tcb_pre_option_page_on_front' );
function tcb_pre_option_page_on_front( $false ){
  global $static_theme_name;
  $theme = wp_get_theme();
  if( $theme->name == $static_theme_name ):
    return 30;

  return false;

This bit of code either needs to go in a plugin, or it can be put in both theme’s functions.php. Change the theme name as required.

Disable Google Analytics in WordPress theme preview

My Preview Problem
Whilst playing around with some theme switching (having one theme do some stuff, then trigger activating a new theme), I noticed that my Google page visits were going up on a site that is not public. That’s when I realised I had the analytics code for that site in my header and that previewing it was triggering a page hit.

Often it is easier to exclude logged in (or just admin) user page hits, but not always.

The Disabling Solution
The answer is easy, just wrap your code in a logical block using the is_preview() WordPress function.

if( !is_preview() ):
<script type="text/javascript">// <![CDATA[
// ]]></script>
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-123456-1']);
    _gaq.push(['_setDomainName', 'tcbarrett.com']);

    (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);


Sometimes it is the little things that help!

Using WordPress page templates to restrict access to content

If you have a complex site, perhaps extending WordPress roles by adding your own custom roles. Or even just making extensive use of the core roles. You may have need to quickly create pages that are only readably by certain groups of users. I try to use capabilities over roles for checking these sorts of things, as often you don’t want to exclude users that a role that you consider superior (e.g. checking for ‘subscriber‘ means that ‘editor‘ users cannot see the page, whereas checking for ‘edit_posts‘ means everyone who has a role of ‘contributor‘ or above can view the page).

/* Template Name: Restricted to Contributors and above */
if ( ! current_user_can( 'edit_posts' ) ) {
  wp_redirect( wp_login_url( get_permalink() ), 302 );
  exit( 0 );

If you don’t want it to redirect to the login page, but instead display a message in place of the post content, then you will need to use it as a conditional around the loop. This is a little trickier to give an example of, as it depends