16 Vital Checks Before Releasing a WordPress Theme

16 Vital Checks Before Releasing a WordPress Theme

Tutorial Details
  • Topic: WordPress
  • Difficulty: Beginner

Releasing a WordPress theme on a marketplace, such as ThemeForest, where the audience is so large and diverse, has some challenges. You cannot test a solution directly with the client. You need to plan in advance for all edge cases, and ensure that your theme is as customizable as possible. If you’re inexperienced, chances are that some things will unfortunately slip through the cracks. Luckily for you, we have drawn on our hard-earned wisdom to help you avoid repeating the same mistakes we made.


1: Don’t Display Comments on Protected Posts

WordPress has the option to make a post password-protected: visitors should be able to access this type of content only after typing in the password. You do not need to do anything special concerning the post itself, but if you forget to check before displaying comments, visitors will still see all comments on the protected post, which sort of defeats the purpose of protecting the post in the first place. You can remedy this with a simple check in comments.php:

<?php if ( post_password_required() ): ?> 
     <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view and post comments.' , 'mytheme' ); ?></p>
</div>
<?php 
        return;
      endif;
?>

2: Display Attachments Correctly

There is a special template file, attachment.php, which is used when a visitor clicks on an attachment. Attachments can be images, videos, music files . . . whatever is inserted with the attachment buttons on the editor:

Attachment buttons

Creating attachment.php is not obligatory: if the template is not there, the browser will just display the file, with an appropriate plugin if necessary. I would say that the main advantage of attachment.php is that when the visitor decides to see, for example, an image at full size, the site navigation remains accessible. You can also display some customized information about the attachment. The default TwentyTen theme in WordPress 3.0 has an interesting attachment.php which displays image sizes.

if ( wp_attachment_is_image() ) {
        echo ' |  ';
        $metadata = wp_get_attachment_metadata();
        printf( __( 'Full size is %s pixels', 'twentyten'),
                     sprintf( '<a href="%1$s" title="%2$s">%3$s × %4$s</a>',
                         wp_get_attachment_url(),
                         esc_attr( __('Link to full-size image', 'twentyten') ),
                         $metadata['width'],
                         $metadata['height']
                     )
       );
}

3: Introduce Right-To-Left Support

You might have heard about supporting right to left languages, but unless you are proficient in one of those languages yourself, you might imagine that it is all very complicated.

Introducing support in your theme for languages that are written right-to-left, such as Arabic and Hebrew, is actually quite easy. The styles in rtl.css will override those in the main style.css when the the WP_LANG variable in settings.php is set to a right-to-left language, for example, Arabic:

define('WP_LANG', 'ar')

Your rtl.css first needs this declaration:

body {
    direction: rtl;
    unicode-bidi: embed;
}

The first property is self-explanatory. The second one ‘opens an additional level of embedding with respect to the bidirectional algorithm’ (W3C).

The rtl.css file does not need to duplicate every style in style.css, just the things that need to change when reading from left to right. Think as if the site was viewed in a mirror: floats change direction (float: left becomes float: right, and vice versa) and margins and padding are inverted (margin-right: 18px becomes margin-left: 18px; margin-right: 0). Also think of large sections of the site: which direction will the header float? Don’t forget all the small details, like reversing the indents of your definition lists and blockquotes. To get a feel for it, you can try switching the language to Arabic or Hebrew on sites like Facebook or Wikipedia, or visit international sites like Al Jazeera.

Believe it or not, that’s about all there is to know.

Reference


4: Supply an Editor Style

To style the TinyMCE editor that comes with WordPress, just create a file named editor-style.css in your theme directory. It’s very easy to fill, as you only need to match the typography with that on the main stylesheet, and there is no need to worry about block layout. TinyMCE has some quirks though. You can avoid the lines being too long by setting a max-width property on the .mceContentBody class.

Editor is too wide
Editor has usable width

If you are including support for right-to-left languages via rtl.css, you should also add a file named editor-style-rtl.css, as some properties, such as list margins and paddings, need to also change in the editor.


5: Make Paginated Entries Work

Paginated entries (not to be confused with a paginated list of entries) are separated into pages by their author with the <!–nextpage–> Quicktag. Admittedly, this feature does not seem to get much use on most WordPress sites, but if you forget to do your part, visitors will be unable to read beyond the first page. To allow the whole content to be read, you must use the wp_link_pages tag within The Loop

wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number'));

For a post with three pages, this outputs the following:

<strong>Pages:</strong> 1 2 3

Visitors can then click on the page numbers to read the whole post. The complete documentation for this function can be found on the WordPress codex.


6: Style Default Widgets

While you can’t style every possible widget under the sun, it is a good idea to check that every widget supplied with WordPress displays convincingly. All of them can receive an optional title and some have different appearances. For example, the Category widget can display as a dropdown and also display multiple levels of nested categories or tags, so make sure you are styling nested lists. Pay particular attention to the Calendar wiget. It’s a table, and you’ll generally want the days to be centered in their cells, so that they align with the week days in the header. On the first picture, numbers look slightly out of place, while they are correctly aligned on the second picture.

Finally, it will help if you start by devising good styles for the .widget class, as it will be applied to all widgets, even those coming from third parties. With flexible layouts in particular, make sure your widgets do not stretch excessively, as that makes them look really weird.


7: Make Threaded Comments Usable

Comments are a bit of a design conundrum. There is a lot of stuff to display (avatars, commenters names, comment dates, comment body, reply buttons), so you need to give it quite a bit of space, but, at the same time, it should not overwhelm the main content, and should be visually distinct in some way. Threaded comments compound all these difficulties, because you also need to distinguish replies. Generally, this is achieved with a margin, but as you cannot know how many levels of replies there will be, you always risk either not allowing for enough width or allowing for too much.

Also, keep in mind that the reply form will not only appear at the bottom of the page, but also in the middle of the comment thread when someone clicks the reply button. So margins and padding should be adequate for both cases. There is also the ‘cancel reply’ link which has to be styled and positioned.

Comment reply form

Finally, you should ensure that comment pagination works, that comments render correctly, both when there are very few, and when there are many, and that threaded comments do not overflow the boundaries of their container. Be careful not to mash comments together, and don’t forget to check the layout for when avatars are both enabled and disabled.


8: Do not Forget wp_footer() and wp_head()

Call wp_footer() just before closing the body tag, and wp_head() just before the closing head tag. Both functions are action hooks, which can be used by plugin and theme developers. If you leave them out, some features and plugins may not work, including custom headers.

Reference


9: Support Thumbnails

Although many themes still rely on plugins, such as TimThumb, WordPress, since 2.9, includes support for thumbnails (‘featured images’) out of the box. To take advantage of this functionality, you just add some lines in functions.php:

add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 70, 70 );

The first line tells WordPress your theme supports thumbnails, while the second forces the thumbnail size to 70x70px, to avoid breaking your layout with differently sized thumbnails. Additionally, you can choose the resizing policy. The example above will just resize the image, while

set_post_thumbnail_size( 70, 70, TRUE );

will also crop the image to make it fit the given ratio. You can also make additional thumbnail sizes available, to use them in different areas of the site:

add_image_size( 'big-thumb', 500, 500 );

Now,

the_post_thumbnail();

displays a 70×70 thumbnail and

the_post_thumbnail( 'big-thumb' );

displays a 500×500 thumbnail.

Reference


10: Support Custom Menus

WordPress 3.0 introduced the long awaited custom menus, so it’s about time to make your users profit from this feature. After registering theme support, like so:

register_nav_menu( 'main_nav', __( 'Main navigation menu', 'mytheme' ) );

. . . you can display a custom menu with wp_nav_menu():

    wp_nav_menu( array( 'theme_location' => 'main_nav' ) );

Be careful, as the system allows you to insert nested elements, which can lead to strange results if you do not plan for them.

The border extends in a weird shape. Nested items have bullets and look jumbled.

Even if you supply dropdowns or navbar style menus, it is difficult to elegantly display more than so many levels of navigation. To protect your layout, either decide a level below which all elements will display the same, or disable displaying lower levels. For example, to limit the display to two levels, use:

wp_nav_menu( array( 'depth' => 2) );

11: Enable Custom Backgrounds

This is a new feature in WordPress 3.0, and it’s also the easiest to implement. It’s literally one line:

add_custom_background();

That’s it! Users can now choose any custom background they want:

Background selection interface.

12: Enable Custom Headers

In the same spirit, but with a little more effort, you can allow to change the site header’s background, and also the site title color. This feature won’t work unless you start by defining a bunch of constants. Replace ‘yourwidth’ and ‘yourheight’ with whatever measurements fit your theme:

define( 'HEADER_TEXTCOLOR', '000' );
define( 'HEADER_IMAGE', get_bloginfo( 'stylesheet_directory' ) . 'path/to/your/image' );
define( 'HEADER_IMAGE_WIDTH', 'yourwidth' );
define( 'HEADER_IMAGE_HEIGHT', 'yourheight' );

Once this is in place, you need to write the function which will apply the background to your header. As there is no standard markup for a site header, WordPress cannot guess how to apply the required CSS for you. For example, to add a custom background to the div with the ‘header’ id, do this:

<?php
function mytheme_header_image() {
?>
     <style type="css">
         #header { background: url(<?php header_image(); ?>) no-repeat; }
    </style> 
<?php
}
?>

You also need to create a function, say mytheme_admin_preview_header(), to style the preview pane in the admin to match the final result. The preview area has the #headimg id, while the site title and the site description have ids of #name and #desc. Experiment with the preview until you are satisfied. Finally, to enable the Appearance > Header panel, call:

add_custom_image_header( 'mytheme_header_image', 'mytheme_admin_preview_header' );

Reference


13: Make User-Visible Strings Translatable

Not everyone wishes their blog to display in English. Wrap every string users need to read with the __() if you wish to translate it, or _e() if you also wish to echo it, like:

__('Hello', 'mytheme') 
_e('Hello', 'mytheme') // Also prints the translated string.

The second argument should be a unique identifier for your theme, so that different translations do not conflict.

After each string has wrapped in a translation function, you need to use the makepot.php script. The recommended way to obtain this script is to install Subversion, then run:

svn co http://svn.automattic.com/WordPress-i18n/tools/trunk

You will obtain a directory, named ‘trunk’ containing, among others, makepot.php.
The script is run like this

php makepot.php wp-theme mytheme

mytheme is the path to your theme directory. You will obtain a file named mytheme.pot, which is ready to be used in a program, such as Poedit to produce a .po file containing a translation.

To finish up, you need to tell WordPress where the translations live in your theme directory, for example:

load_theme_textdomain( 'mytheme', TEMPLATEPATH . '/languages');

Here, ‘mytheme’ is the unique identifier for your theme; the second argument tells where the translation files are. TEMPLATEPATH is a special constant defined by WordPress which always points to the current theme’s directory.

Reference


14: Handle Custom Fields

This one is a bit optional, as you might want to leave that to the users’ or other developers’ discretion. You will know that WordPress supports adding custom fields on each post. In many themes, these fields usually do not display at all, unless they are used for a special feature. Some users might be confused, because they believe they can use custom fields to output any information they wish.

The custom fields interface

There is a function,

the_meta()

to be called in The Loop, which displays all custom fields attached to a post, as an unordered list in key:value form. Admittedly, it’s not terribly useful, but it might be better than leaving someone wondering why custom fields are not displaying anywhere.

Reference


15: Make Sure Everything Looks Consistent

One of the difficulties of theming a dynamic system, such as WordPress is that there are many edge cases which do not occur too often, but that can still ruin the appearance of the site when they do. Think of posts with closed comments, or with very short bodies. Make sure no weird spaces creep in, or that elements are not mashed together because something is not displayed. The comment section might not be displayed if comments are not allowed, or a password entry field might replace the usual post content when the post is password protected.

Also, try to match the way comments are styled with the main body. This last point requires particular care, because, generally speaking, space is more limited in the comment area — especially when using threaded comments and each reply is knocked to the right (or the left, for RTL).


16: Use the WordPress.org Theme Unit Test

WordPress.org offers a sample content file that you can import into your WordPress installation, which contains an assortment of test posts, pages and images.

To import the file in WordPress 3.0, you need first to install the WordPress Importer plugin. Then, choose Tools > Import > WordPress. Be sure to check the ‘Download and import file attachments’ tickbox when prompted. Otherwise, you won’t get the images associated to some sample posts.

After the import completes, you can use this checklist to determine whether the content displays as it should.


Conclusion

We’ve learned that things to watch out for come in multple varieties. Some are seldom-used features, others are customization opportunities, while others are more akin to common design problems, which will repeat with any WordPress site you design. Our list is certainly far from exhaustive, so we want to hear from you in the comments! What do you think are the most often forgotten pieces of functionality?

Tags: Wordpress
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.brandonmartinez.com/ Brandon Martinez

    Excellent!

  • http://aaronbentley.co.uk Aaron Bentley

    Nice list of checks, good article :)

  • Dan

    Great Post! I think most of these functions are already available if the theme developer would learn to create a Child Theme off of TwentyTen.

    Maybe a post on creating a custom Child Theme.

  • http://connorcrosby.me Connor Crosby

    Helpful, thanks!

  • http://www.broof.de BroOf

    Excellent tips!

  • ksbomj

    Great tutorial! Thanks!

  • http://freecss.info CSS Tutorials

    Nice list but I really don’t think some of these are necessary, or vital for that matter.

  • http://pixielogic.com/ Chris Ren

    Nice Tips!

  • http://brianswebdesign.com Brian Temecula

    I’ve made some custom WordPress templates for customers, and normally don’t have to go through a checklist this thorough, but it’s nice to have a checklist like this, because there is a lot to think about.

  • Rasoul Hamidian

    Hi, can you please make a tutorial on integrating mybb users to wordpress ? I can’t find it anywhere

  • Allan

    I hate WP. So awful coded and inflexible CMS.

    • http://webdesignandsuch.com mike i

      Riiiiiiiiiight

  • bjorn

    this tutorial is very useful, but there are some points I never use. But I just can’t figure out how to implement the nav_menu as main navigation. Is it really just that simple?

  • http://www.bransonwerner.com Branson Werner

    Great article. Theres so much that goes into a theme, and constant updates to WP, this is a great list.

    Something else to add:

    17. CSS and page validation. W3C now has an all-in-one validator service called Unicorn (http://validator.w3.org/unicorn/)

    • Sahan

      Thank you :)

  • http://thedigitalyardsale.com Digital Yard Sale

    Great checklist. I’m a newbie and only a couple of months into WordPress development and web development in general for that matter. So this will definitely come in handy for future endeavors.

    Thanks!

  • http://www.crearedesign.co.uk Steve Maggs

    And now I know why I haven’t yet made my own theme! That’s quite some checklist, but invaluable when I do finally make a theme, until then I’ll keep using Starkers and dressing it up to suit my needs. Thanks.

  • http://www.vunkyblog.net Vunky

    Great Post,

    Glad to see a more in-depth article on tutsplus. Will definitely bookmark this.

  • http://dmitry-scriptin.blogspot.com/ Scriptin

    Thanks for the sample content file! I always wanted to have it.

  • http://www.thedevelopertuts.com Bratu Sebastian

    Great article, although I’m not such a big fan of WordPress

  • http://www.leonamarant.com/ LA

    very useful! never knew that you could edit the style of the TinyMCE editor. Very powerful. Question, can you change the editor style for specific pages…like ‘editor-style-5.css” (where 5 is the page id)? Many times my home page uses a different stylesheet than the rest of my theme (and also, my pages and posts are slightly (if not vastly) different as well. This is a great post!

    • http://ludovf.net/ Ludovico Fischer
      Author

      Thank you for your positive comments.
      I’m afraid that you cannot define a different editor style depending on the page being edited. Just try to hit a happy medium, I guess.

  • http://www.tristarwebdesign.co.uk tristar1983

    Brilliant post, that is going to come in very handy!

  • http://www.whoisbexxie.com Bexxie

    This is perfect timing as I just started working on a WordPress theme that I plan to giveaway. Bookmarked! Thanks!

  • http://wuwuts.com MarvinCspw

    Excellent Releasing Details

  • http://twitter.com/pelfusion PelFusion

    Yah! it is very important check list

  • http://www.mikaelbertheau.fr Mikael

    Very useful todo list!

  • http://www.cairnslogo.com.au Cairns

    I am just in the process of creating my first theme, this is a good checklist.

  • http://c3mdigital.com/ Chris Olbekson

    This is great information and also applies to getting your theme hosted on the WordPress.org theme repository. I’ve spent the last few months reviewing themes for acceptance into the repository and the number one reason a theme gets rejected is due to using depreciated calls and WP_DEBUG errors. To test for depreciated calls you can use the Log Depreciated Notices Plugin and adding define(‘WP_DEBUG’, true); to your config.php file.

    Also there is an updated version of the test review data located at: http://svn.automattic.com/wpcom-themes/test-data.2010-08-02.xml

    You should also make sure you use wp_enqueue_script to register any js files to prevent conflicts with any plugins users might add later.

  • http://www.sjlwebdesign.co.uk SJL Web Design

    Really helpful list of points!! I will definitely be bookmarking this as a reference for when I build my next wordpress site!!!

    Thanks!

  • http://www.izuddinhelmi.com izuddin.helmi

    Cool checklist! ;)

  • http://www.dsaportfolio.com.br/ Diego SA

    Ah, perfect timing! It will come in handy for a WordPress currently job I got recently. Some of the tips you’ve posted here are quite interesting and I’ve never ever seen before!

    But I think it will be a little bit rare and hard I get used to features like the header and background customization via WP admin, even it being awesome features! But it’s something I really need to use more frequently in a good way to show a layout within a high level of awesomeness and customization.
    Guess I will test it in a currently job! =D

    But anyway, this post is a must-be bookmarking post! Congratulations!

  • Yogi – ThemeWarrior

    Awesome checklist!

  • http://www.jennamolby.com Jenna Molby

    Very helpful, thank you!

  • http://www.draftpress.com Charlie Patel

    Great list for theme developers. Thanks for posting it.

  • http://www.tomhermans.com Tom Hermans

    Great article, some of them I knew about, the trick with the multiple thumbnail-sizes was new.

    Question: do those thumbnail-images get cached somewhere (like timthumb does) ?
    Or are they resized on upload or .. ?

  • http://www.dynamicguru.com Mujtaba Ahmed

    A big thankyou for this!
    I always missed a few of these checks…

  • http://www.dynamicguru.com/mujtaba/ Mujtaba Ahmed

    Another important thing is to use “wp_enqueue_script” to load any javascript to prevent conflict with any other plugin js…

  • http://socialmediafanatics.com/ Social Media Fanatics

    This is a very helpful article. I really like using wordpress, it made me use my brilliant MIND. LOL

  • http://bcic.com.vn Kiem Dinh Xay Dung

    it’s very clear! nice post. i’m building up about 50 WP sites now. so, these tips help me a lot!
    thanks!

  • http://www.eshban.com Eshban Bahadur

    It is one of the best tutorials for wordpress. THanks for sharing.

  • Jamal Mohamed

    Great tips.

    The tinyMCE editor styling will not display unless you add add_editor_style(); in your functions.php. By the way, editor-style-rtl.css is needed if you are planning to support right-to-left languages.

    Thanks for sharing.

  • http://www.webtwitter.eu Seth

    This helped me a lot. Thanks.

  • http://funnysmsjokes.co.in eguru

    Nice Tips.. Thanks!

  • http://mallikcomedy.com mallik

    Thanks for sharing nice WP tips.

  • http://louyblog.wordpress.com/ Louy

    Nice, thanks :)
    btw there’s a plugin called the “RTLer” that generates the rtl.css from your style.css, take a look here: http://wordpress.org/extend/plugins/rtler/

  • http://www.espreson.com/ Espreson

    Such a common tutorial..Need to be followed on wordpress 3.0 development..

  • http://www.posicionamientomkt.com Joaquin Poggi

    Really nice post! Thanks

  • http://www.designjuices.co.uk/2010/08/50-exquisite-wine-label-designs/ jared thompson

    good to have a checklist for all the buddy wp developers and designers out there!

  • http://pixert.com Kate Mag

    These vital checks really help Theme Developers a lot. Thanks

  • http://seolar.de seolar

    A really good article. Simple to read, well to understand. And really useful tips. Now I will write a theme page (template) for my WordPress blog for attached files. I forgot to write this one. But with your article I remembered to write this one.

    Thanks a lot for this post!

  • http://charmthemes.com Ahmed

    Perfect check list

  • http://loige.posterous.com Loige

    Really, really a great article ;) I’ve learned a lot!
    Well done man!