child themes in wordpress

39
slideshare.net/jdcohan Child Themes Get Started On The Right Foot With Creating Jeff Cohan, nSiteful Web Builders WordCamp Atlanta 2012 @jdcohan [email protected]

Upload: jeff-cohan

Post on 08-May-2015

1.657 views

Category:

Technology


0 download

DESCRIPTION

For WordCamp ATL 2012

TRANSCRIPT

Page 1: Child Themes in WordPress

slideshare.net/jdcohan

Child Themes

Get Started On The Right Foot With Creating

Jeff Cohan, nSiteful Web Builders

WordCamp Atlanta 2012

@jdcohan

[email protected]

Page 2: Child Themes in WordPress

slideshare.net/jdcohan

Survey

• By a show of hands, who...– has given presentations on child themes?– has created and used child themes?– understands child themes enough to explain

what they are?

Page 3: Child Themes in WordPress

slideshare.net/jdcohan

What is a WordPress Theme?

• A collection of files that work together to determine the look and presentation (and functionality) of a WordPress site.

• Consists of:– style sheet(s)– template file(s)– images– code files (functions)

Page 4: Child Themes in WordPress

slideshare.net/jdcohan

What is a Child Theme?

• Official Definition:– A WordPress child theme is a theme that

inherits the functionality of another theme, called the parent theme, and allows you to modify, or add to, the functionality of that parent theme.

• Inherit = either or both of:– supplement– override

Page 5: Child Themes in WordPress

slideshare.net/jdcohan

WHY Use Child Themes?

• Security:– Avoid screwing up a perfectly good theme,

crashing site

• Maintainability:– Preserves your modifications when parent

theme is updated

• Self-Education:– Helps you learn WordPress' innards (clone

and go)

Page 6: Child Themes in WordPress

slideshare.net/jdcohan

WHEN to Use Child Themes:

• As soon as you want to modify the site's look, presentation, or functionality

• I.e., ALWAYS!

• Examples:– change color scheme– change "read more"– match blog to non-WP site– change footer contents*

Page 7: Child Themes in WordPress

slideshare.net/jdcohan

How?

• Create a directory under/wp-content/themes/– as sibling directory of parent (yeah:

counterintuitive)

• Upload a properly-formatted (?) stylesheet.

• Voila. Honest. Voila.

Page 8: Child Themes in WordPress

slideshare.net/jdcohan

Child Theme Components

• Required:– Style Sheet: style.css (S and/or O)

• Optional:– Template files (O)– functions.php (S)– other files (images, JavaScript, php includes)

• REALLY optional:– screenshot.png (300x225)

Page 9: Child Themes in WordPress

slideshare.net/jdcohan

Style Sheet (style.css) Format

• Required Commented Information Block (at top)– Required elements:

• Theme Name• Template (parent theme name)

– Optional elements:• Theme URI, Description, Author URI, Author,

Version

• @import directives (optional)

Page 10: Child Themes in WordPress

slideshare.net/jdcohan

Sample Child Style Sheet

Page 11: Child Themes in WordPress

slideshare.net/jdcohan

Pecking Order Quick Review

• style.css: supplements and/or overrides– The Cascade: weight, origin, specificity, order

• Template Files: override– understand Template Hierarchy

• functions.php: supplements - overridable!– child loads first– use function names NOT used by parent

theme*

Page 12: Child Themes in WordPress

slideshare.net/jdcohan

Mods Through CSS

• Options:– Override any rule from parent*

• *beware of specificity

– Add rule(s) for new components

• Let's change that footer with CSS:#footer { background: url(images/cclogos.png)

no-repeat right center transparent;}

Page 13: Child Themes in WordPress

slideshare.net/jdcohan

Mods Through Templates

• Building Blocks:– Template Tags– Function Reference– Template Hierarchy

Page 14: Child Themes in WordPress

slideshare.net/jdcohan

WordPress Template Hierarchy

Page 15: Child Themes in WordPress

slideshare.net/jdcohan

Mods Through Templates

• Options:– replace parent template

• e.g., customized home.php

– add specific template lacking in parent• e.g., tag.php instead of archives.php

– add custom template• e.g., custom php code

• Let's change that footer with template...

Page 16: Child Themes in WordPress

slideshare.net/jdcohan

Mods Through Functions

• Building Blocks:– Function Reference– Hooks (Actions & Filters)

• Examples:– favicon link– change the "read more" text– complex scripts

Page 17: Child Themes in WordPress

slideshare.net/jdcohan

Favicon via Function

Page 18: Child Themes in WordPress

slideshare.net/jdcohan

Read More via Function

Page 19: Child Themes in WordPress

slideshare.net/jdcohan

All of the Above

• Custom Template, Custom Scripts, Custom CSS

Page 20: Child Themes in WordPress

slideshare.net/jdcohan

Add Blog to Existing Site

• client might love existing site

• client might not have the budget to redo site in WordPress

• client just wants a blog that integrates seamlessly

Page 21: Child Themes in WordPress

slideshare.net/jdcohan

Eaton Academy Main Site

Page 22: Child Themes in WordPress

slideshare.net/jdcohan

Eaton Academy Blog

Page 23: Child Themes in WordPress

slideshare.net/jdcohan

Lessons In Your Home Main Site

Page 24: Child Themes in WordPress

slideshare.net/jdcohan

Lessons In Your Home Blog

Page 25: Child Themes in WordPress

slideshare.net/jdcohan

Starkers!

• The completely naked theme for WordPress

• Free of all style, presentational elements, and non-semantic markup, Starkers is the perfect ‘blank slate’ for your projects, as it’s a stripped-back version of the ‘Twenty Ten’ theme that ships with WordPress.

• http://starkerstheme.com/

Page 26: Child Themes in WordPress

slideshare.net/jdcohan

Why Starkers?

• What's Removed:– non-semantic presentational class names

(class="alignleft")– non-semantic HTML elements (<hr />, <br />– unnecessary elements (<div class="entry">)

• What's Kept:– IDs to preserve functionality

(<h3 id="respond">)

Page 27: Child Themes in WordPress

slideshare.net/jdcohan

Wait for it...

Page 28: Child Themes in WordPress

slideshare.net/jdcohan

Resources

Page 29: Child Themes in WordPress

slideshare.net/jdcohan

WordPress Function Reference

Page 30: Child Themes in WordPress

slideshare.net/jdcohan

WordPress Template Tags

Page 31: Child Themes in WordPress

slideshare.net/jdcohan

PHP.NET

Page 32: Child Themes in WordPress

slideshare.net/jdcohan

PHPXref of WP Trunk (Yoast)

Page 33: Child Themes in WordPress

slideshare.net/jdcohan

WordPress Answers - Stack Exchange

Page 34: Child Themes in WordPress

slideshare.net/jdcohan

LinkedIn WordPress Group

Page 35: Child Themes in WordPress

slideshare.net/jdcohan

Color Scheme Designer

Page 36: Child Themes in WordPress

slideshare.net/jdcohan

Digging Into WordPress

Page 37: Child Themes in WordPress

slideshare.net/jdcohan

CSS: The Definitive Guide 3rd Edition

Page 38: Child Themes in WordPress

slideshare.net/jdcohan

TopStyle

Page 39: Child Themes in WordPress

slideshare.net/jdcohan

Firebug