Book Details

ISBN 139781847198440

Paperback312 pages

Book Description

Themes are among the most powerful features that can be used to customize a web site and give it a professional look, especially in WordPress. Using custom themes you can brand your site for a particular corporate image, ensure standards compliance, and create easily navigable layouts. But most WordPress users still continue to use default themes as developing and deploying themes that are flexible and easily maintainable is not always straightforward and lot of issues pop up during the process.

This easy-to-use step-by-step guide will help you create powerful themes for your WordPress web site, and solve your theme development problems in a quick and effective way. It enables you to take full control over your site's design and branding and make it look smarter.

WordPress is distributed with two ready-to-use themes. You can use these themes to give a common look to your website, or use the techniques described in this book to create custom themes. This book includes over 100 useful recipes to help you get started and create advanced themes. It starts with the basics of WordPress themes and creating a theme from scratch. Then, it covers how to enhance your template and add effects to get a rich look. You will learn how to manage pages, categories, and tags for your blogs, and how to make your posts look unique. You will also learn about the comment system and sidebars that will help you give a new feel to your blog and web site.

This book will help you through the most common problems encountered when developing a WordPress theme. You will get tips to enhance your design skill and eventually enhance your blog's design.

Table of Contents

Chapter 1: WordPress Theme Basics

Introduction

Finding documentation on WordPress.org

Downloading themes from the WordPress theme repository

Downloading themes from third-party websites

Installing and activating a theme

Displaying the blog name

Getting the absolute directory path of the active theme

Creating a theme from scratch

Creating a child theme

Creating a theme by using a theme framework

Adding expected WordPress hooks

Including PHP files from your theme

Chapter 2: Creating Navigation

Introduction

Listing all of the pages that exist on a blog

Listing all of the categories defined for a blog

Listing all of the tags in use on a blog

Highlighting the current page in the navigation

Adding a search function to a theme

Getting the category page link from a category name

Displaying page links only if the destination page exists

Creating a category drop-down menu

Creating drop-downs using child pages

Chapter 3: The Loop

Introduction

Creating a basic Loop

Displaying ads after every third post

Removing posts in a particular category

Removing posts with a particular tag

Highlighting sticky posts

Creating multiple loops in a single template

Displaying only posts in a particular category

Styling every other post differently

Styling posts in a particular category differently

Showing every post in a category on a category archive page

Chapter 4: Template Tags

Introduction

Displaying the post title

Automatically limiting the number of words of content

Determining if the user is on a specific page

Determining if the user is viewing a post in a particular category

Displaying the post date for each post

Highlighting search terms in post content

Displaying login/logout links

Adding navigation through older/newer posts

Displaying an edit link for posts

Displaying custom field content

Displaying a post author's avatar

Chapter 5: Comments

Introduction

Displaying a comment form on a post

Displaying comments on a post

Displaying the latest comments on your blog

Highlighting the post author's comments

Alternating the style for comments

Displaying threaded comments properly

Chapter 6: Sidebars

Introduction

Using the Text widget for custom sidebar content

Including a dynamic sidebar in your theme

Including multiple dynamic sidebars in your theme

Setting the default widgets for a sidebar in your theme

Positioning multiple sidebars in your theme by using CSS

Styling the appearance of sidebars in your theme by using CSS

Displaying different widgets on different

Showing asides in the sidebar by using the Miniposts plugin

Adding an interactive Facebook-style wall to a sidebar by using jQuery

Chapter 7: Custom Page Templates

Introduction

Creating a simple page template

Creating an archives page template

Creating a taxonomy navigation template

Displaying author avatars and descriptions

Creating a table of contents page template

Showing your pictures from Flickr

Displaying a special template for a specific category

Chapter 8: Integrating Media

Introduction

Aligning images properly within a post

Styling image galleries

Styling image captions

Creating a media template

Creating a media template for a specific media type

Displaying a related image for every post

Creating video posts by using the Viper's Video QuickTags plug-in

Chapter 9: Showing Author Information

Introduction

Getting author data via an author's ID

Dynamically displaying the author's name and linked e-mail address

Listing all of the published authors on a site

Listing the authors who most recently published a post

Listing authors by the total number of comments that their posts have received

Adding a custom user field to display an author's Twitter link

Chapter 10: Adding JavaScript Effects

Introduction

Linking to your theme's JavaScript files directly

Adding JavaScript files to your theme programmatically

Adding a bundled library to your theme programmatically

Creating a featured post slider

Making sidebar widgets toggle-able

Adding a font size toggle

Chapter 11: Advanced WordPress Themes

Introduction

Adding a theme options page

Allowing for multiple theme color schemes

Changing the default Gravatar icon for your theme

Registering shortcodes for your theme

Localizing your theme

Displaying information based on the logged-in user's role

Packaging your theme for distribution

Uploading your theme to the WordPress.org theme repository

Chapter 12: Layout

Introduction

Adding a skip navigation link for usability

Centering your site's layout in the browser window

Setting up a randomly-rotating header image

Making theme components drag-and-drop

Creating a global toolbar for your theme

Creating tabbed navigation for your theme

What You Will Learn

Enhance your page templates, optimize the use of images, and add effects to them

List your pages, categories, and tags on a blog and create navigation

Stylize your posts to make them look interesting

Display, format, and tweak the comment system to attract the visitors

Add sophistication to your dynamic web site using popular JavaScript libraries

Package and distribute your theme using the WordPress.org theme repository

Display auxiliary information about the post being displayed using dynamic sidebars

Empower your end users to change the contents displayed in the theme's sidebar without involving a programmer

Change the style of your theme depending upon image content and time

Authors

Nick Ohrn

Nick Ohrn has been creating with WordPress for more than five years and has worked with some of the biggest media companies in the USA. In his day to day work, he deals with the WordPress source, creates custom themes and plugins, and helps his clients and customers utilize WordPress to run their sites and their businesses. Nick has a Bachelor’s of Science in Computer Science from the Rose-Hulman Institute of Technology and works full time as a web developer with an emphasis in WordPress development. He resides in Seattle, WA and works with people and companies from around the world.

Lee Jordan

Lee Jordan is a web developer with a large collection of web technology acronyms on her resume that sound like the names of laundry detergents and cause glazed expressions in school children. She designs and maintains internal and external enterprise-level websites and web-based applications as part of a project team for a privately held technical services company. Her work includes proposing, writing, and editing web content and user guides people actually read. She began her career in 1997 as a web designer after graduating from Florida State University with a Bachelor of Fine Arts, where she swears that she missed at least one home football game while in the computer lab. Lee later convinced Seminole Community College to give her a Web Programming degree in 2003, even though her final project was a Java-based application that actually contained a usable help file. Web development topics or whatever she can think of at the time are posted on her blog at http://leejordan.net.

Table of Contents

Chapter 1: WordPress Theme Basics

Introduction

Finding documentation on WordPress.org

Downloading themes from the WordPress theme repository

Downloading themes from third-party websites

Installing and activating a theme

Displaying the blog name

Getting the absolute directory path of the active theme

Creating a theme from scratch

Creating a child theme

Creating a theme by using a theme framework

Adding expected WordPress hooks

Including PHP files from your theme

Chapter 2: Creating Navigation

Introduction

Listing all of the pages that exist on a blog

Listing all of the categories defined for a blog

Listing all of the tags in use on a blog

Highlighting the current page in the navigation

Adding a search function to a theme

Getting the category page link from a category name

Displaying page links only if the destination page exists

Creating a category drop-down menu

Creating drop-downs using child pages

Chapter 3: The Loop

Introduction

Creating a basic Loop

Displaying ads after every third post

Removing posts in a particular category

Removing posts with a particular tag

Highlighting sticky posts

Creating multiple loops in a single template

Displaying only posts in a particular category

Styling every other post differently

Styling posts in a particular category differently

Showing every post in a category on a category archive page

Chapter 4: Template Tags

Introduction

Displaying the post title

Automatically limiting the number of words of content

Determining if the user is on a specific page

Determining if the user is viewing a post in a particular category

Displaying the post date for each post

Highlighting search terms in post content

Displaying login/logout links

Adding navigation through older/newer posts

Displaying an edit link for posts

Displaying custom field content

Displaying a post author's avatar

Chapter 5: Comments

Introduction

Displaying a comment form on a post

Displaying comments on a post

Displaying the latest comments on your blog

Highlighting the post author's comments

Alternating the style for comments

Displaying threaded comments properly

Chapter 6: Sidebars

Introduction

Using the Text widget for custom sidebar content

Including a dynamic sidebar in your theme

Including multiple dynamic sidebars in your theme

Setting the default widgets for a sidebar in your theme

Positioning multiple sidebars in your theme by using CSS

Styling the appearance of sidebars in your theme by using CSS

Displaying different widgets on different

Showing asides in the sidebar by using the Miniposts plugin

Adding an interactive Facebook-style wall to a sidebar by using jQuery

Chapter 7: Custom Page Templates

Introduction

Creating a simple page template

Creating an archives page template

Creating a taxonomy navigation template

Displaying author avatars and descriptions

Creating a table of contents page template

Showing your pictures from Flickr

Displaying a special template for a specific category

Chapter 8: Integrating Media

Introduction

Aligning images properly within a post

Styling image galleries

Styling image captions

Creating a media template

Creating a media template for a specific media type

Displaying a related image for every post

Creating video posts by using the Viper's Video QuickTags plug-in

Chapter 9: Showing Author Information

Introduction

Getting author data via an author's ID

Dynamically displaying the author's name and linked e-mail address

Listing all of the published authors on a site

Listing the authors who most recently published a post

Listing authors by the total number of comments that their posts have received

Alerts & Offers

Series & Level

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

Learning

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Beginner's Guide

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Essentials

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

Cookbook

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Blueprints

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Mastering

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Starting

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Progressing

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.