For those of you who prefer to use TextMate when developing anything for WordPress might enjoy to learn how to use TextMate’s bundles to enhance your development process.

I have assembled a couple of my favorite and most commonly used commands that you can add to your TextMate. First, I want to say that I used Coda for a long time until I had some acquaintances suggest to me that I use TextMate and I am yet to go back.

First off, what are bundles you might ask. TextMate bundles (from what I understand them to be) are a way for you to store snippets of code for easy access in the future. I find them most useful when I find myself going to the WordPress Codex multiple times for the same piece of code. In this article I will go over the basics of the bundle I am running on my machine and how to add them to your TextMate.

1. First, you will need to decide which common code snippets you would like to add to a quick access repository.


2. Next we need to add the snippets to TextMate. Open Textmate and go to Bundles -> Bundle Editor -> Show Bundle Editor.  At the bottom of your screen you will see a button with a plus sign and a down arrow. Click that button and then at the bottom of the drop down select New Bundle and give it a name. For this example I use the name: Brady Nord’s WordPress Bundle.

3. Third, click on the bundle that you just created and named so that the line highlights. Now you will need to go back down to the button with the plus sign and drop down arrow and select New Snippet and give it a name that is meaningful to what the snippet of code will do. Now don’t get intimidated at this part as I know how you might feel. When I first saw this code here I was not sure what it was asking of me. All this code is just an example of how to write your syntax if you so choose to use it.  For this example you can just delete all of it. Now I am going to show you how to add a Snippet to quickly call the function to register a sidebar in your WordPress theme.

    1. Name your Snippet Function Sidebar.
    2. In the “Edit Snippet: “Function Sidebar”” editor copy and paste the following code:
      001 # Register Sidebar - $1
      003 if ( function_exists('register_sidebar') )
      004 register_sidebar(array(
      005 'name' => '$2',
      006 'description' => '$3',
      007 'before_widget' => '</pre>
      008 <div class="$4">',
      009 'after_widget' => '</div>
      010 <pre>
      011 ',
      012 'before_title' => '</pre>
      013 <div class="$5">',
      014 'after_title' => '</div>
      015 <pre>
      016 ',
      017 ));


  1. Next to Activation: select Tab Trigger and then write function sidebar in the field next to it.
  2. You can leave the Scope Selector blank for now.

Now go ahead and open up a TextMate file and type function sidebar and then press tab after you typed the command. You should see the above code snippet displayed. So to break it down very simply is, you have defined a trigger ( function sidebar ) and then you have said that when you type those words and press the tab key then display the associated code snippet. It’s that simple.

I am sure that you are wondering what the $1, $2, etc are in the above code. Those are what TextMate calls Tab Stops. Tab Stops define where the cursor will first be placed when the code is called. So when you call the function sidebar snippet you have your cursor immediately placed where the $1 is. Now once you give your Sidebar a name then just press the tab key again and it will jump to $2 etc. Tab Stops are really cool and make for quick coding.

I will place a handful of handy snippets that I use on a daily basis below.

Functions to be quickly called in your functions.php file:

Sidebars – Tab Trigger: function sidebar

001 # Register Sidebar - $1
003 if ( function_exists('register_sidebar') )
004 register_sidebar(array(
005 'name' => '$2',
006 'description' => '$3',
007 'before_widget' => '<div class="$4">',
008 'after_widget' => '</div>',
009 'before_title' => '<div class="$5">',
010 'after_title' => '</div>',
011 ));

3.0 Menus – Tab Trigger: function menus

001 // 3.0 Menus
002 add_theme_support( 'menus' );
004 add_action ( 'init', 'register_navmenus');
005 function register_navmenus() {
007 register_nav_menus(array('$1'=> __('$2') )); }

And here are some common calls to use throughout the theme files:

Call Sidebar – Tab Trigger: call sidebar

001 <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('$1') ) : ?>
003 <?php endif; ?>

Call Menus – Tab Trigger: call menus

001 <?php wp_nav_menu( array( 'theme_location' => '$1' , 'container_class' => '$2' ) ); ?>

Call Search – Tab Trigger: call search

001 <?php get_search_form(); ?>

Call Loop – Tab Trigger: call loop

001 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
003     $1
005 <?php endwhile; ?>
007 <?php endif; ?>

I hope this helps you in setting up some quick Snippets to help you develop in WordPress much quicker. I have many more that I use throughout all WordPress themes that if you are interested I can definitely add to this list so be sure to let me know what you would like to see.

Do you develop with TextMate? If so, what features do you use everyday?