www.it-ebooks.info WordPress Theme Development Beginner's Guide Third Edition Learn how to design and build great WordPress themes Rachel McCollin Tessa Blakeley Silver BIRMINGHAM - MUMBAI www.it-ebooks.info WordPress Theme Development Beginner's Guide Third Edition Copyright © 2013 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: May 2008 Second edition: November 2009 Third edition: March 2013 Production Reference: 1130313 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-84951-422-4 www.packtpub.com Cover Image by Vinayak Chittar (vinayak.chittar@gmail.com) www.it-ebooks.info Credits Authors Project Coordinator Rachel McCollin Michelle Quadros Tessa Blakeley Silver Proofreader Kevin McGowan Reviewers Srikanth AD Indexer Steve Graham Rekha Nair Acquisition Editor Graphics Kartikey Pandey Valentina D'Silva Lead Technical Editors Ankita Shashi Unnati Shah Technical Editors Worrell Lewis Production Coordinator Conidon Miranda Cover Work Conidon Miranda Amit Ramadas www.it-ebooks.info About the Authors Rachel McCollin is a web designer and developer specializing in WordPress development She discovered WordPress when looking for a CMS that made the transition from static HTML relatively straightforward, and hasn't looked back since Rachel runs Compass Design, a web design agency based in Birmingham, England, but with clients across the UK and internationally The agency was established in 2010 and quickly began specializing in building WordPress themes and sites, with a slant towards responsive themes The agency now has a great team of designers and developers, including some WordPress specialists I've learned most of what I know about WordPress from the web design community I'd like to thank all of the WordPress developers and designers who have inspired and taught me, in particular the organizing team for WordCampUK, without whom I never would have even thought of writing about WordPress A number of friends and colleagues have provided support with my writing and have helped me develop my WordPress skills, as well as giving useful feedback for this book They include Mark Wilkinson, Jon Hickman, Scott Evans, Tammie Lister, Nivi Morales, and Jonny Allbut Rob Ashton at Emphasis has set me straight on grammar when I've needed it Kartikey Pandey at Packt Publishing showed the confidence in my work to ask me to take on my second project for Packt Publishing—I'm grateful for this, and for his positivity and encouragement Most importantly, my husband Pete has encouraged and supported me all along, and has spent many Saturdays entertaining our two boys, so that I could get on with the task of writing www.it-ebooks.info Tessa Blakeley Silver's background is in print design and traditional illustration She evolved over the years into web and multi-media development, where she focuses on usability and interface design Prior to starting her consulting and development company, hyper3media (pronounced hyper-cube media) http://hyper3media.com, Tessa was the VP of Interactive Technologies at eHigherEducation, an online learning and technology company developing compelling multimedia simulations, interactions, and games that met online educational requirements like 508, AICC, and SCORM She has also worked as a consultant and freelancer for J Walter Thompson and The Diamond Trading Company (formerly known as DeBeers) and was a Design Specialist and Senior Associate for PricewaterhouseCoopers' East Region Marketing department Tessa authors several design and web technology blogs Joomla! Template Design is her first book www.it-ebooks.info About the Reviewers Srikanth is a web developer, passionate about developing and optimizing websites for better user experience, performance, and search engine visibility He is particularly interested in adapting content management systems for developing structured and scalable websites Check out his portfolio at http://srikanth.me Steve Graham is a programmer turned web-developer with years of experience, building large-scale databases to run manufacturing control and international banking systems His experience at the back-end of the IT industry has given him a keen understanding of the needs of the final users and it's this knowledge and expertise that he brings to his work with WordPress As one half of the Internet Mentor team (www.internet-mentor.co.uk) his passion is developing themes that help to solve some of the most frustrating aspects of marketing online Focusing on the key business objectives, his aim for all clients is to ensure that they derive measurable and sustainable direct results that drive business growth He spends much of his time working on theme development for niche areas Rather than producing themes that are so generic that the only real reason they appeal to a market is the name of the theme or the type of background image, these themes are designed to provide real solutions and are created with a a knowledge and thorough understanding of the challenges their end users have to overcome Steve is also a passionate speaker and networking skills coach, who is able to bring a different perspective to the messages his clients are delivering in the online world Relationship marketing is key to success in the 21st century and having an understanding of how effective both the on and off-line networks can be, is essential to the success of almost all businesses www.it-ebooks.info www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy Get in touch with us at service@packtpub.com for more details At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packts online digital book library Here, you can access, read and search across Packt's entire library of books. Why Subscribe? Fully searchable across every book published by Packt Copy and paste, print and bookmark content On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books Simply use your login credentials for immediate access www.it-ebooks.info www.it-ebooks.info Table of Contents Preface 1 Chapter 1: Getting Started as a WordPress Theme Designer Overview of WordPress perks Does a WordPress site have to be a blog? Pick a theme or design of your own Drawbacks of using an off-the-shelf theme What about premium themes and frameworks? What exactly is a premium theme 10 What is a framework theme 10 Core technology you should understand 12 WordPress 12 CSS 13 HTML 13 PHP 13 Other helpful technologies 14 Tools of the trade 14 HTML editor 14 Graphics editor 15 Web browser 15 Basics of a WordPress theme 16 The template hierarchy 17 The Loop 17 Template tags and API hooks 17 Our development strategies 18 Fonts and typefaces 18 A CSS strategy – font sizing with ems www.it-ebooks.info 19 Chapter Now, below that, add the code for the description: