PacktLib: WordPress 2.8 Themes Cookbook

WordPress 2.8 Themes Cookbook

Credits

About the Authors

About the Reviewers

Preface

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

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

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

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

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

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

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

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

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

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

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

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