Adding Viewport Meta Tag via WordPress Theme Functions

Add the viewport meta tag with a WordPress hook via your theme’s functions file to allow responsive web design and mobile-friendly themes

meta-viewport-thumbWith all the responsive web design activity over the past few years, I hope that any theme or site we work on we’re able to make responsive to some extent. An important part of making a web site responsive is adding a viewport meta tag to your html. Without explicitly stating our viewport, the mobile browsers will scale down the website to fit into their ‘viewport’. This is a good thing, since if it was a full website and the browser didn’t scale it down, you’d only see the top left corner, or some small section of the site. This viewport was introduced by apple for iOS and has spread to most mobile devices since. There are viewport properties or parameters we can set with this meta tag such as width and scale and can even use some device aware variables (like ‘device-width’) to set these values.

A WordPress Meta Viewport Hook

I usually end up using the following hook to add a viewport meta tag to my head in wordpress. I set the viewport width to match the width of the device. Then I set the initial scale to 1. Some go and set the maximum-scale to 1 as well. This would prevent users from zooming in on your site. I advocate that we should allow users to zoom if they wish since it is a gesture they may be used to and may still need (no matter how nice your RWD is, they may need/want to see it bigger). RWD is about giving the user a better layout for whatever device they are on, not restricting how they view it.

[cc lang=”php”]
/////////////////////////////////////////////////////////////////////////////////
// Add viewport meta tag to head
//
function viewport_meta() {
?>

"Common" Breakpoints are missing the point

Great article from Jeremy Keith about the nonsense it is to use breakpoints determined by devices. The whole point of responsive web design is to make your designs flexible. Let's not only target certain widths, let's just finish the thought and make it a great experience no matter what width it is. Let the content determine the breakpoints.

Embedded Link

Adactio: Journal—Fanfare for the common breakpoint
“Common” breakpoints are the new fold.

circlecube's New Clothes – Theme Redesign

blog-circlecube-com pageThanks for your patience as I’ve been tinkering with the theme, layout and css of circlecube.com.

old theme
old theme

The last theme I used was badly broken with the wordpress 2.8 update and then I noticed the developer actually discontinued support for the theme! So I had an opportunity to delve into wordpress theming. I’d been reading about child themes and wanted a nice stable basic parent theme to build from. Cue thematic framework. It was a great learning experience building a child theme for myself, many thanks to Ian Stewart for all the tips help and tuts to help me though it, not to mention for creating thematic .

new theme
new theme

I’ve kept the color scheme and general look of the site the same. So the reason I’m going on about it is I think I’m finished… and I’m asking you to let me know if you see anything that looks odd or fishy, or even just want to make a suggestion or comment on how much you like/hate the redesign. Comment on this post or contact me!

And as always, if there’s something you would like me to write about or have questions you can also contact me. I’ve even set up a poll in the sidebar showing post ideas I have which you can vote on and encourage me to write the one(s) you want most first! So let me know what you want, it encourages me to write more. And be sure to subscribe to the circlecube rss feed so you won’t miss anything that’s coming up!