Developing WordPress Themes Using Responsive Frameworks

Developing WordPress Themes Using Responsive Frameworks

Tutorial Details
  • Program: WordPress
  • Difficulty: Beginner
  • Version: 3+
  • Estimated Completion Time: 15 minutes

Responsive design is slowly but surely becoming an expected standard for web developers. This tutorial will show you how to add a responsive framework to your next WordPress theme.


What Is Responsive Design?

It used to be you only had to worry about website consistency across multiple browsers, but now we have to look at the bigger picture – consistency across multiple devices. The computer used to be our only gateway to the Internet, but now we jump online from our phones, TVs, tablets and who knows what else will come down the pipe. Having your website appropriately render and perform on any device should be a top priority this year.

Responsive design is all about making things fluid and adjusting according to screen size. Although WordPress doesn’t always play nice with responsive design methods, there are ways it can be achieved. How responsive you decide to make your website is really about how much time you want to spend doing it.


Responsive Frameworks

There are several responsive frameworks out there to choose from. You might want to spend some time investigating each one to determine which has the included features your project might require. If you aren’t sure where to start, here are a few to consider:

Bootstrap

Bootstrap from Twitter is built on a responsive 12 column grid. It has included fixed- and fluid-width layouts based on that system. It also comes with support for optional JavaScript plug-ins such as an image carousel, Typeahead, togglable tabs, and many more.

Less Framework

Less Framework is based on 4 layouts and 3 sets of typographic presets. Less Framework uses a default layout as a starting point and then uses CSS3 media queries to code ‘child layouts’.

Foundation

Foundation is a grid system based on 12-columns that do not have a fixed width; they can vary based on the resolution of the screen or size of the window. Foundation comes pre-packaged with buttons and built in form styles, alerts, and more.

YAML

YAML is a multi-column layout based on a grid system with percentage widths. It comes with several built in features and supports several jQuery plugins such as Accessible Tabs and SyncHeight.

This list of frameworks is hardly complete, but for the sake of this tutorial, I’m going to show you how to incorporate Foundation into your next WordPress theme.


Step 1 Downloading and Applying the Framework

To get started, go download Foundation and add the files to your css and js folders in your theme’s directory. The easiest way to add the required files to your theme would be to use wp_enqueue_script and wp_enqueue_style.

For this tutorial I’m going to show you what you place in your functions.php file to make Foundation work right off the bat, but for more details on adding files this way, check out the tutorial on how to include JavaScript and CSS in your theme.

To add the needed JavaScript for Foundation to work properly in your theme, you need to create a function that calls the wp_enqueue_script to serve them up.

function responsive_scripts_basic()
{
	//register scripts for our theme
	wp_register_script('foundation-mod', get_template_directory_uri() . '/js/modernizr.foundation.js', array( 'jquery' ), true );
	wp_register_script('foundation-main', get_template_directory_uri() . '/js/foundation.js', true );
	wp_register_script('foundation-app', get_template_directory_uri() . '/js/app.js', true );
	wp_enqueue_script( 'foundation-mod' );
	wp_enqueue_script( 'foundation-main' );
	wp_enqueue_script( 'foundation-app' );
}
add_action( 'wp_enqueue_scripts', 'responsive_scripts_basic', 5 );

Next, add the Foundation stylesheets to make the grid flexible. Paste this function after the one you just created.

function responsive_styles()
{
	//register styles for our theme
	wp_register_style( 'foundation-style', get_template_directory_uri() . '/css/foundation.css', array(), 'all' );
	wp_register_style( 'foundation-appstyle', get_template_directory_uri() . '/css/app.css', array(), 'all');
	wp_enqueue_style( 'foundation-style' );
	wp_enqueue_style( 'foundation-appstyle' );
}
add_action( 'wp_enqueue_scripts', 'responsive_styles' );

Once saved, go back and check your source code to make sure your files were added correctly. It should look something like this:

<link rel='stylesheet' id='foundation-style-css'  href='http://thatonegeek.com/sandbox/wp-content/themes/Starkers/css/foundation.css?ver=all' type='text/css' media='all' />
<link rel='stylesheet' id='foundation-appstyle-css'  href='http://thatonegeek.com/sandbox/wp-content/themes/Starkers/css/app.css?ver=all' type='text/css' media='all' />
<script type='text/javascript' src='http://thatonegeek.com/sandbox/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
<script type='text/javascript' src='http://thatonegeek.com/sandbox/wp-content/themes/Starkers/js/modernizr.foundation.js?ver=1'></script>
<script type='text/javascript' src='http://thatonegeek.com/sandbox/wp-content/themes/Starkers/js/foundation.js?ver=3.3.1'></script>
<script type='text/javascript' src='http://thatonegeek.com/sandbox/wp-content/themes/Starkers/js/app.js?ver=3.3.1'></script>

Step 2 Add IE Only Conditions

Everyone loves to go that extra mile to make things work in Internet Explorer right? To make sure your Foundation framework stays responsive in Internet Explorer, you need to add a few conditional statements. These should go in your header.php file before the closing head tag.

<!--[if lt IE 9]>
<link rel="stylesheet" href="/css/ie.css">
<![endif]-->

<!--IE Fix for HTML5 Tags-->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->>

Step 3 Working With the Framework

Now that your theme has Foundation setup, to make use of all its responsive features you need to design using the Foundation grid system. Like other responsive frameworks, it’s a system made up of 12 columns. Other included features are pre-set button styles, tabs, tables and much more. Check out the Foundation documentation to view all bells and whistles and instructions on how to work with the grid.


Going With a Pre-Packaged Theme

There are plenty of free and premium WordPress themes available that make use of responsive design. If you would rather start with something out of the box, you can try out these themes:

WordPress Bootstrap, By 320Press

WordPress Bootstrap is a theme developed on Twitter’s Bootstrap v.2.0.1. It’s fully responsive with four different page templates to choose from, shortcodes, and multiple sidebar options. Once installed, you can check out bootswatch.com to download different color versions of the theme.

iTheme2

Based on the Themify framework, iTheme2 uses media queries to target different displays, comes with a customizable feature slider, a social media widget, two different theme skins and you can have up to four footer widgets.

Responsive Twenty Ten

The Responsive Twenty Ten theme supports flexible images, margins, and mobile images. It was created as a child theme for the included Twenty Ten theme.

Good Minimal (Premium)

Good Minimal is a clean, minimalist responsive layout that adapts to a multitude of displays and devices. Good Minimal comes with two different styles, supports unlimited custom sidebars, shortcodes, multiple drop down menus, and several other features.

Modulo (Premium)

Modulo is a responsive, fluid layout, supporting google fonts, shortcodes, multiple sliders, portfolio page templates and color customization. Modulo also comes with 5 custom widgets, including one for recent posts with thumbnail support.


Conclusion

Responsive design is continuing to grow in popularity and knowing how to utilize it within your future theme construction will be crucial for success. Whether you are adding a framework to your theme or using a pre-built theme supporting responsive design, your clients are going to expect multiple device support as a basic service.

Are themes you create responsive? Do you use a responsive framework we haven’t mentioned? Tell us all about it in the comments below!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.uxde.net/ Toan Nguyen Minh

    Very cool stuffs. I have leaned many things from this article. Thank a lot!

  • Jakub

    Man this is really great post. It is so much helpfull and informativ for me. Big thanks.

  • http://www.uidesigns.ro/ Catalin

    Thanks Sarah. I was just looking for an article like this one.

  • http://www.jaskni.com JASKNi

    Thanks for this tutorial.

  • http://www.mailostudios.com Paul

    Nice article! I actually use the Foundation button styles on most of my projects outside Foundation.

    I think Bones Responsive (http://themble.com/bones/#bones-showcase) needs to be added to this list. I’ve been using Bones as a started point for all my projects and it’s absolutely thorough HTML5 code with the most comprehensive and highly detailed stylesheet I’ve ever seen. Also, it’s comes natively with LESS and SASS integration!

    • http://thatonegeek.com Sarah

      I will definitely check out Bones, I only listed a few to keep it short and sweet, but from the looks of it Bones seems like a solid choice.

      • Bahador

        WordPress Bootstrap is based on Bones.

    • Nick

      I’m a huge bones fan. I use it with almost every custom WP theme I develop.

      • http://www.simonswiss.com Simon

        Quick question regarding Bones – For some reason the google webfont i use seems to be too “thick”. I try to set up to font-weight:400 but it seems it keeps defaulting to 700. Any idea why?

    • Tubia

      I agree with Paul, Bones seems to be a great starting point for a responsive theme development. I’m new to wordpress theme developing but Bones seems to semplifies the understanding of theme structure. The commented stylesheet is awesome!

  • Ferik

    Thanks,
    hopefully, you could make the screencast series for this tut :)

  • http://wordimpressed.com Devin Walker

    I definitely second that the Bones responsive design be added to this list. It’s super solid.

  • http://www.stevendsanders.com/ Steven D. Sanders

    I have been using the Roots theme for client sites lately. It uses Twitter Bootstrap 2.0 and is responsive by default.

    http://www.rootstheme.com/

  • http://www.webdesignlift.com Windo

    I’m using ZURB’s Foundation for client project. (my blog coming soon I hope :D ) at this moment, thanks for sharing how to apply the css and js, I think the problem is, it is annoying to update the framework files when it already embedded inside our theme. I hope this can be a light to my problem.

    Also you forgot to mention the skeleton framework. It is nice and probably as good as ZURB’s foundation had.

    Thank U Sarah :)

    • Mike

      I use skeleton framework. It’s a very well organized and responsive wordpress framework. It takes some getting used to but its great.

      • http://www.webdesignlift.com Windo

        Hi Mike, have you used ZURB’s Foundation ? am in the middle of decision whether to use one of them. I’m guessing skeleton is derived from 960 gs, it has alpha and omega classes, but still wanna read more about the skeleton and maybe try it for a simple page.

        • mike

          @windo, No I haven’t but I have been hearing more about it lately. I just like how well Skeleton is organized. The theme options it comes with is great too. In any case it’s definitely worth checking out.

  • http://www.whatsthebigidea.com David Radovanovic

    Thanks for the nice and easy tutorial. I have some questions about Foundation framework:

    1. In order to convert your WordPress theme to Foundation framework the div classes would have to be changed? Wouldn’t that kill your present theme’s CSS layout by changing the classes?

    2. Is there a way to preserve the existing layout of your WordPress theme as you add the responsive (fluid) characteristics (via js and css)?

    Thanks again. BTW – quickly implemented on the Twenty Ten theme in 15 minutes.

    • http://thatonegeek.com Sarah

      Good questions. I would assume it would break your current theme if you started just randomly changing the classes without real thought behind it. You might try putting your current design against a column grid to see where/what things would need to change. OR just do media queries to implement responsiveness if you don’t want to reformat your css.

    • http://www.mailostudios.com Paul

      I think it’s better to rebuild your site from scratch, if possible. The whole idea of responsive design is to plan out a site from it’s beginning with a responsive layout in mind – especially the mobile first approach. So if it’s within your means then I would definitely suggest taking this as an importunity to redesign! The headaches of trying to convert a fixed width site to a responsive layout are definitely more than it would take to quickly whip up a new site (which would not take long if using a framework). Even if you convert a site and it looks good at the first look, you’ll find that there will be a multitude of little bugs that pop up and you’ll have to fix – especially with forms and even just classes, which is why I advocate starting from scratch!

  • Pingback: Developing WordPress Themes Using Responsive Frameworks | Wptuts+ » Web Design

  • http://imclement.com Clement

    IT’s all about responsive framework. It’s based on browser or wordpress?

  • Pingback: Tweet-Parade (no.11 March 2012) | gonzoblog.nl

  • http://www.wpfix.org Wpfix

    Nice tutorial on responsive framework.

  • http://afrocosmopolitan.com Afro-Austrian

    Great tut Sarah, i really enjoyed going through it. Hope to come across more interesting tuts like this here. Thanks for sharing!

  • http://cbarn.es Chris Barnes

    Great article! I too am a big proponent of the Bones framework. Has really helped me get my most recent WordPress projects off the ground very quickly.

  • http://wpresponsivethemes.com wordpress responsive themes

    Great article, but I agree…probably best to build the theme up from scratch. Get tor edesign, cleaner code….

  • Pingback: Wordpress - Theme - Development - Techniques | Pearltrees

  • http://www.reanimatie.com Rean

    You’ve got to check out Bones. It’s a killer responsive and clean framework, especially after the latest update where less is integrated.

  • http://coder-design.com/ coder-design

    Thanks for sharing. It is a good tutorial.

  • Pingback: » How to test your responsive website design » TourKick.com » Blog Archive

  • Pingback: Tweet-Parade (no.12 Mar 2012) | gonzoblog.nl

  • Pingback: Themes | 4Drive me!

  • Pingback: Sivuston optimointiAndreas Koutsoukos | Andreas Koutsoukos

  • Dev

    I’ll try this as soon as I get home. Thank you :-)

  • Pingback: Eliminar los atributos de ancho y alto del cargador de archivos WordPress | Tecnologia, Desarrollo Web, Posicionamiento Web SEO

  • Pingback: Eliminar los atributos de ancho y alto del cargador de archivos WordPress | Ayuda

  • Pingback: レスポンシブフレームワークを使ったWordpressテーマの開発 | 備忘録

  • Pingback: 79+ Best Responsive Wordpress Themes That Will Sky Rocket Your Website

  • http://www.minimalmachine.com gitano

    Thanks. I tried to add Zurb Foundation to _s (underscore) theme by Theme Shaper and it’s work.

  • http://smashfreakz.com Triyas

    Great article. I’ll try this as soon

  • Pingback: 100 Resources Help You Become Web Designer and Developer | Tech and Project

  • http://chrisfield.com chris

    Heaps of fun. Thank you, Sarah!

    My two-cents to add is in regards to folks using child themes. I know – why use a child theme if you are this far into mucky details, right? I dunno, but I am. So anyway you’ll need to swap out a function call for WordPress to find your js:

    wp_register_script(‘foundation-mod’, get_template_directory_uri() . ‘/js/modernizr.foundation.js’, array( ‘jquery’ ), true );
    wp_register_script(‘foundation-main’, get_template_directory_uri() . ‘/js/foundation.js’, true );
    wp_register_script(‘foundation-app’, get_template_directory_uri() . ‘/js/app.js’, true );

    should become:

    wp_register_script(‘foundation-mod’, get_stylesheet_directory_uri() . ‘/js/modernizr.foundation.js’, array( ‘jquery’ ), true );
    wp_register_script(‘foundation-main’, get_stylesheet_directory_uri() . ‘/js/foundation.js’, true );
    wp_register_script(‘foundation-app’, get_stylesheet_directory_uri() . ‘/js/app.js’, true );

    get_stylesheet_directory_uri() is the important piece. get_template_directory_uri() directs WordPress to the parent theme, but you want it directed to your child theme.

  • Maciej
  • http://www.wpshouter.com WpShouter

    Thank you so much for this excellent tutorial. I have been looking for a clear, simply explanation of how to design and use responsive themes for several days and this is the best one I have found. In just a few short steps, you have expertly explained the parameters to add and why they should be added. You saved me a ton of time and confusion.

  • Mrto2

    Should we paste the Code from Step1 into theme’s functions.php file? It is not working for me for even default twenty ten theme.
    Any Idea?

  • http://www.facebook.com/mike.phillips.56679 Mike Phillips

    The version of jquery in the new wordpress installation is lower than the current jquery library from zurb foundation. Is it safe to use wp_deregister_script to deregister the wordpress version of jquery.js and then register and enqueue the newer jquery.js included from the foundation download? I was reading about the conflict wrappers but did not totally understand the impact of changing to a different , up to date, jquery.js file.

    • http://wp.tutsplus.com/ Japh

      Hi Mike, there is really no need to update from the version of jQuery included in your WordPress installation. With each update of WordPress itself, they include the lastest stable version of jQuery anyway. When WordPress 3.5 is released in December it will have at least jQuery 1.8.2 included.

      Deregistering is not recommended unless you have full-control of the site, and always will, and fully understand the potential repercussions in terms of conflicts with plugins, etc.

      • http://www.facebook.com/mike.phillips.56679 Mike Phillips

        OK great. this is very helpful. I appreciate your fast reply.

  • Siddhanth Aryan

    one more best responsive framwork is there -> http://github.com/kanthvallampati/IVORY

  • nurul

    love this one, i use adamantium :)

  • Pingback: Top 160 Tutoriais WordPress – incluindo Basico, Desenvolvimento e Plugins – Site para Empresas – Blog sobre Internet e Criação de Site

  • Jeff Harding

    Very nice tut I would like to see an update if possible for foundation 4.

  • http://www.facebook.com/people/Ahmad-Zainudin-M/100002819067243 Ahmad Zainudin M

    Thank you for very helpul tutorial, I’m using Foundation :)