Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

WordPress 2.8 Themes Cookbook
WordPress 2.8 Themes Cookbook
WordPress 2.8 Themes Cookbook
Ebook768 pages5 hours

WordPress 2.8 Themes Cookbook

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Each recipe comprises step-by-step instructions followed by the analysis of what was done in each task and other useful information. The book is designed so that you can read it chapter by chapter, or you can look at the list of recipes and refer to them in no particular order. There are plenty of useful screenshots to make learning easier for you. This book is for WordPress developers who want to create powerful themes for their blogs and web sites to impress and influence visitors. This book expects working knowledge of the WordPress platform. Knowledge of HTML and CSS would also be useful.
LanguageEnglish
Release dateJul 1, 2010
ISBN9781847198457
WordPress 2.8 Themes Cookbook

Related to WordPress 2.8 Themes Cookbook

Related ebooks

Information Technology For You

View More

Related articles

Reviews for WordPress 2.8 Themes Cookbook

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    WordPress 2.8 Themes Cookbook - Nick Ohrn

    Table of Contents

    WordPress 2.8 Themes Cookbook

    Credits

    About the Authors

    About the Reviewers

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Errata

    Piracy

    Questions

    1. WordPress Theme Basics

    Introduction

    Finding documentation on WordPress.org

    Getting ready

    How to do it...

    How it works...

    Downloading themes from the WordPress theme repository

    Getting ready

    How to do it...

    How it works...

    There's more...

    Try search

    Tag filter

    Downloading themes from third-party websites

    How to do it...

    How it works...

    There's more...

    Installing and activating a theme

    Getting ready

    How to do it...

    How it works...

    Displaying the blog name

    How to do it...

    How it works...

    There's more...

    Blog info available

    Retrieving information without displaying it

    Getting the absolute directory path of the active theme

    How to do it...

    How it works...

    Creating a theme from scratch

    How to do it...

    There's more...

    Recognized WordPress files

    Organizing a theme

    See also

    Creating a child theme

    Getting ready

    How to do it...

    How it works...

    There's more...

    Maintaining default styling

    See also

    Creating a theme by using a theme framework

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Adding expected WordPress hooks

    How to do it...

    How it works...

    There's more...

    Including PHP files from your theme

    Getting ready

    How to do it...

    How it works...

    There's more...

    2. Creating Navigation

    Introduction

    Listing all of the pages that exist on a blog

    How to do it...

    How it works...

    There's more...

    Passing parameters

    Listing all of the categories defined for a blog

    How to do it...

    How it works...

    There's more...

    Passing parameters

    Listing all of the tags in use on a blog

    How to do it...

    How it works...

    There's more...

    Passing parameters

    Highlighting the current page in the navigation

    How to do it...

    How it works...

    There's more...

    Adding a search function to a theme

    How to do it...

    How it works...

    There's more...

    Getting the category page link from a category name

    How to do it...

    How it works...

    Displaying page links only if the destination page exists

    How to do it...

    How it works...

    Creating a category drop-down menu

    How to do it...

    How it works...

    Creating drop-downs using child pages

    Getting started

    How to do it...

    How it works...

    See also

    3. The Loop

    Introduction

    Creating a basic Loop

    How to do it...

    How it works...

    Displaying ads after every third post

    How to do it...

    How it works...

    Removing posts in a particular category

    How to do it...

    How it works...

    Removing posts with a particular tag

    How to do it...

    How it works...

    Highlighting sticky posts

    How to do it...

    How it works...

    Creating multiple loops in a single template

    How to do it...

    How it works...

    There's more…

    Displaying only posts in a particular category

    How to do it...

    How it works...

    Styling every other post differently

    How to do it...

    How it works...

    Styling posts in a particular category differently

    How to do it...

    How it works...

    Showing every post in a category on a category archive page

    How to do it...

    How it works...

    See also

    4. Template Tags

    Introduction

    Displaying the post title

    How to do it...

    How it works...

    There's more...

    See also

    Automatically limiting the number of words of content

    How to do it...

    How it works...

    Determining if the user is on a specific page

    How to do it...

    How it works...

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

    How to do it...

    How it works...

    There's more...

    Displaying the post date for each post

    How to do it...

    How it works...

    Highlighting search terms in post content

    How to do it...

    How it works...

    Displaying login/logout links

    How to do it...

    How it works...

    There's more...

    Adding navigation through older/newer posts

    How to do it...

    How it works...

    There's more...

    Displaying an edit link for posts

    How to do it...

    How it works...

    Displaying custom field content

    How to do it...

    How it works...

    There's more...

    Displaying a post author's avatar

    How to do it...

    How it works...

    5. Comments

    Introduction

    Displaying a comment form on a post

    How to do it...

    How it works...

    There's more...

    Displaying comments on a post

    How to do it...

    How it works...

    There's more...

    Separating comments and trackbacks

    Changing the Avatar size

    Available parameters

    Displaying the latest comments on your blog

    How to do it...

    How it works...

    There's more...

    Getting only certain comment types

    Getting only comments for a particular post

    Available parameters

    Highlighting the post author's comments

    How to do it...

    How it works...

    See also

    Alternating the style for comments

    How to do it...

    How it works...

    See also

    Displaying threaded comments properly

    How to do it...

    How it works...

    See also

    6. Sidebars

    Introduction

    Using the Text widget for custom sidebar content

    Getting ready

    How to do it...

    Including a dynamic sidebar in your theme

    Getting ready

    How to do it...

    How it works...

    There's more...

    Finding inspiring sidebars for your theme design

    Including multiple dynamic sidebars in your theme

    Getting ready

    How to do it...

    How it works...

    There's more...

    Sidebar parameters

    Default content

    Setting the default widgets for a sidebar in your theme

    Getting ready

    How to do it...

    How it works...

    There's more...

    Widget IDs

    Positioning multiple sidebars in your theme by using CSS

    Getting ready

    How to do it...

    How it works...

    There's more...

    Position: absolute versus float

    Doing more with design and layout

    Styling the appearance of sidebars in your theme by using CSS

    Getting ready

    How to do it…

    How it works…

    There's more…

    Design and Layouts: The WordPress codex

    Sandbox: The theme for maximum appearance options

    Displaying different widgets on different pages by using the Widget Logic plugin and conditional tags

    Getting ready

    How to do it...

    How it works...

    There's more...

    Getting more out of conditional tags

    Specific sidebars for custom theme pages

    Showing asides in the sidebar by using the Miniposts plugin

    Getting ready

    How to do it...

    How it works...

    There's more…

    Creating custom asides

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

    Getting ready

    How to do it...

    How it works...

    There's more...

    Doing more with WP Wall

    7. Custom Page Templates

    Introduction

    Creating a simple page template

    Getting ready

    How to do it...

    How it works...

    Creating an archives page template

    Getting ready

    How to do it...

    How it works...

    There's more...

    Listing archive links

    Listing Categories

    See also

    Creating a taxonomy navigation template

    Getting ready

    How to do it...

    How it works...

    See also

    Displaying author avatars and descriptions

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating a table of contents page template

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Showing your pictures from Flickr

    Getting ready

    How to do it...

    How it works...

    See also

    Displaying a special template for a specific category

    Getting ready

    How to do it...

    How it works...

    8. Integrating Media

    Introduction

    Aligning images properly within a post

    Getting started

    How to do it...

    How it works...

    Styling image galleries

    Getting started

    How to do it...

    How it works...

    Styling image captions

    Getting started

    How to do it...

    How it works...

    See also

    Creating a media template

    Getting started

    How to do it...

    How it works...

    See also

    Creating a media template for a specific media type

    Getting started

    How to do it...

    How it works...

    There's more…

    Using file and image attachments in WordPress

    See also

    Displaying a related image for every post

    Getting started

    How to do it...

    How it works...

    There's more…

    Using Viper's Regenerate Thumbnails plug-in

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

    Getting started

    How to do it…

    How it works...

    There's more…

    Adapting your site for mobile content viewing by using the WPtouch theme

    9. Showing Author Information

    Introduction

    Getting author data via an author's ID

    Getting started

    How to do it...

    How it works…

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

    Getting started

    How to do it…

    How it works...

    There's more…

    Dive deeper into data

    Listing all of the published authors on a site

    Getting started

    How to do it...

    How it works...

    Listing the authors who most recently published a post

    Getting started

    How to do it...

    How it works...

    See also

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

    Getting started

    How to do it...

    How it works...

    See also

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

    Getting started

    How to do it...

    How it works...

    There's more…

    Displaying an image next to the 'Follow' link

    10. Adding JavaScript Effects

    Introduction

    Linking to your theme's JavaScript files directly

    Getting started

    How to do it...

    How it works...

    See also

    Adding JavaScript files to your theme programmatically

    Getting started

    How to do it...

    How it works...

    There's more...

    Placing wp_enqueue_script in the footer for better site performance

    Taking advantage of wp_register_script

    Adding a bundled library to your theme programmatically

    Getting started

    How to do it...

    How it works...

    There's more...

    List of bundled scripts

    See also

    Creating a featured post slider

    Getting started

    How to do it...

    How it works...

    There's more…

    Theming your slider with Themeroller

    See also

    Making sidebar widgets toggle-able

    Getting started

    How to do it...

    How it works...

    There's more...

    Remembering the widget's state

    Adding a font size toggle

    How to do it...

    How it works…

    11. Advanced WordPress Themes

    Introduction

    Adding a theme options page

    Getting started

    How to do it...

    How it works...

    There's more…

    Diving into administrative settings for themes

    Allowing for multiple theme color schemes

    Getting started

    How to do it...

    How it works...

    See also

    Changing the default Gravatar icon for your theme

    Getting started

    How to do it...

    How it works...

    There's more...

    Forcing your theme to use your default avatar

    Registering shortcodes for your theme

    How to do it…

    There's more…

    Displaying Twitter trends by using shortcodes in posts

    Localizing your theme

    How to do it…

    How it works…

    There's more…

    Becoming a WordPress theme translator

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

    How to do it…

    How it works…

    There's more…

    Easier ways to use user roles in WordPress 3.0

    Packaging your theme for distribution

    How to do it…

    There's more…

    Is your theme really ready for public release?

    Uploading your theme to the WordPress.org theme repository

    Getting started

    How to do it…

    How it works…

    12. Layout

    Introduction

    Adding a skip navigation link for usability

    Getting started

    How to do it...

    How it works...

    Centering your site's layout in the browser window

    Getting started

    How to do it...

    How it works...

    Setting up a randomly-rotating header image

    Getting started

    How to do it...

    How it works...

    Making theme components drag-and-drop

    Getting started

    How to do it...

    How it works...

    There's more...

    Saving the category order

    See also

    Creating a global toolbar for your theme

    Getting started

    How to do it...

    How it works...

    Creating tabbed navigation for your theme

    Getting started

    How to do it...

    How it works...

    There's more…

    Many menus, many resources

    Index

    WordPress 2.8 Themes Cookbook

    Nick Ohrn


    WordPress 2.8 Themes Cookbook

    Copyright © 2010 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: June 2010

    Production Reference: 1220610

    Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK.

    ISBN 978-1-847198-44-0

    www.packtpub.com

    Cover Image by Vinayak Chittar (<vinayak.chittar@gmail.com>)

    Credits

    Authors

    Lee Jordan

    Nick Ohrn

    Reviewers

    Jose Argudo Blanco

    Taeke Reijenga

    Acquisition Editor

    Sarah Cullington

    Development Editor

    Ved Prakash Jha

    Technical Editor

    Dayan Hyames

    Copy Editors

    Janki Mathuria

    Lakshmi Menon

    Editorial Team Leader

    Akshara Aware

    Project Team Leader

    Lata Basantani

    Project Coordinator

    Srimoyee Ghoshal

    Indexers

    Tejal Daruwale

    Monica Ajmera Mehta

    Proofreader

    Dirk Manuel

    Production Coordinator

    Shantanu Zagade

    Cover Work

    Shantanu Zagade

    About the Authors

    Lee Jordan is a web designer and new media developer who designs and maintains websites, web-based applications, templates, and social media for a privately-held technical services company. She brings a strong design background and concern for the visual and emotional impact of media to web-based projects. Experienced in multiple CMS platforms including Expression Engine, Plone, WordPress, PostNuke, and Google’s Blogger, she has maintained, explored, and used most of them on a day-to-day basis. She spends her spare time as the leader of a local scout troop, taking long hikes with her family in the beautiful North Georgia woods, trying to taste every variety of chocolate that exists, and playing with code and pixels. Design topics, or whatever she can think of at the time, are posted on her blog at http://leejordan.net.

    Lee has previously written two books with Packt Publishing: Project Management with dotProject, and Blogger: Beyond the Basics.

    A big thank you to my family: Brian, Celeste, Jason and Mom for looking over my shoulder and giving hugs when I needed encouragement, knowing when to give me space, and learning way more than they ever wanted to about this WordPress theme stuff. They are responsible for helping me keep my reader’s point of view in mind. I love you all.

    Nick Ohrn holds a bachelors degree in Computer Science from the Rose-Hulman Institute of Technology. He graduated in 2008 and has been running his own independent software development company ever since.

    As an independent business owner, Nick has had the pleasure of working on a variety of high profile projects. He enjoys creating applications that are both usable and have a high-quality codebase. Nick specializes in custom WordPress development and web applications.

    Nick balances his time between programming, managing others, reading, writing on a variety of technical platforms, and contributing to open source software. When he isn’t working, he enjoys weight training, bodybuilding, and other athletic endeavors.

    Find Nick’s custom WordPress development business at http://plugin-developer.com. You can find his personal site at http://nickohrn.com.

    I’d like to first thank my wonderful fiancee and soon to be wife, Angela Tokarz. Without her gentle prompting along the way, this book may never have been finished. Thanks also to Peter Chester and Shane Pearlman for introducing me to the Packt Publishing team.

    Finally, a big thank you to my entire family who showed interest throughout the process and were constantly asking when the book would be done. It is because of them that I have the skills to be able to write this book in the first place.

    About the Reviewers

    Jose Argudo is a web developer from Valencia, Spain. After finishing his studies, he started working for a web design company. Then, six years later, he decided to start working as a freelancer.

    Now that some years have passed as a freelancer, he thinks it’s the best decision he has ever taken—a decision that lets him work with the tools he likes, such as Joomla!, Codeigniter, Cakephp, Jquery and other known open source technologies.

    His desire to learn and share his knowledge has led him to be a regular reviewer of books from Packt, including Drupal E-commerce, Joomla! with Flash, Joomla! 1.5 SEO, Magento 1.3 Theme Design or Symfony 1.3 WebApplication Development.

    Recently he has even published his own book, Codeigniter 1.7, which you can also find at Packt’s site. If you work with php, take a look at it!

    Jose is currently working on a new book for Packt, this time Joomla! related; check for it soon!

    If you want to know more about Jose, you can check his site at www.joseargudo.com.

    To my Brother.

    Taeke Reijenga is the co-founder of Level Level, a young and versatile graphic and web design agency from Rotterdam, The Netherlands.

    Level Level is well known for their WordPress expertise. From a small-scale personal blog to a multilingual corporate website or e-commerce website, Level Level does it all.

    In his spare time Taeke loves to travel, cook a nice meal, and enjoy a good glass of wine with friends.

    You can contact Taeke via http://level-level.com.

    Preface

    In the last few years, WordPress has exploded in popularity. What started as simple blogging software has become an amazingly-capable content management system. As the capabilities of the software have grown, so have the unique and novel ways in which WordPress data is displayed.

    Nowadays, developers and designers utilize the WordPress theme system to build everything from simple blogs to fully-fledged news sites. You can display different content in unique ways, highlight your most important posts and pages, and engage your users by allowing them to comment on and share your content, quickly and easily.

    In short, WordPress makes it easy for people to show the world what they have to offer. Theming WordPress is easy, and template files are readily-modifiable by users of any skill level. However, if you’re willing to put in the time, you will find a powerful system hidden by this simplicity that allows you to build almost anything you want. This book will teach you how to use that power to build robust and high-quality themes that take full advantage of WordPress and the WordPress ecosystem.

    What this book covers

    Chapter 1, WordPress Theme Basics gets you started with developing WordPress themes teaching you about the documentation and finding, creating and installing themes.

    Chapter 2, Creating Navigation shows you how to implement a variety of techniques that allow your users to navigate around your site.

    Chapter 3, The Loop teaches you about The Loop, the main building block of WordPress. It shows you how to display your content in unique and interesting ways, and shows you how to change the data that is fetched and presented.

    Chapter 4, Template Tags shows you how to display the content that the user enters in the administrative back-end. It teaches you to use unique WordPress functions to show titles, content, and other post data.

    Chapter 5, Comments shows you how to start the conversation on your blog by allowing users to view and post comments. It teaches you to modify how the comments are shown and the information shown for each comment.

    Chapter 6, Sidebars covers how to display secondary content on your blog by using WordPress’ fabulous widget and sidebar system.

    Chapter 7, Custom Page Templates shows you unique content and unique needs for displaying it. It teaches you how to use the powerful template system to make WordPress display the content that you want and the way you want it.

    Chapter 8, Integrating Media discusses multimedia types, such as audio and video, which are now commonplace on blogs. It teaches you to take control of how images and media are displayed and create custom media templates for images, audio, video, or any other file type.

    Chapter 9, Showing Author Information introduces why your site’s authors are important. It teaches you how to display author bios, latest posts, and custom data.

    Chapter 10, Adding JavaScript Effects shows you how to make your theme interactive and easy to use, by adding small pieces of JavaScript functionality.

    Chapter 11, Advanced WordPress Themes covers

    Enjoying the preview?
    Page 1 of 1