SlideShare a Scribd company logo
1 of 39
Download to read offline
WordPress Theming Best Practices
for Client-Centric Web Development

Brian Krogsgard - WordSesh 2!

!
Post Status | poststat.us |@post_status
Structuring your
WordPress theme
Assets

•

CSS / JS / Images / fonts

•

Sprites, minified files
Template Hierarchy

•

http://codex.wordpress.org/Template_Hierarchy

•

http://wphierarchy.com/
Template Parts
•

Naming conventions and organization.
•

•
•

Prefix page templates “page-about-template.php” or nest
them in a “page-templates” folder.
For partial templates, use logical and consistent conventions.

Lean toward smaller templates.
•

•

Are you repeating yourself? Make it a template part.

Give good and thorough comment blocks at the top of
templates, even partial ones
Hooks vs templates

•

Or both?
Code Syntax
Follow the guides
•

Seriously, take the time to properly format your
code.

•

http://codex.wordpress.org/
WordPress_Coding_Standards
Entering and exiting PHP

•

In templates versus functions / operational code
•

When in PHP, stay in PHP
Curly brackets versus alternative
syntax for control structures
•

http://php.net/manual/en/controlstructures.alternative-syntax.php

•

http://pippinsplugins.com/please-do-not-usecurly-brackets-in-template-files/

•

http://tommcfarlin.com/commenting-code-blocks/
Function naming norms

•

get_the_{something} vs the_{something}
Alignment

•

Tabs for nesting, spaces for alignment.
Code
Hook Order
•

Core Load http://www.rarst.net/script/wordpresscore-load/

•

Wowza hooks http://codex.wordpress.org/
Plugin_API/Action_Reference

•

Special shoutout to template_redirect
(conditionals)
Action and filters
•

Make your parent themes filterable!
•

Intro: http://pippinsplugins.com/a-quickintroduction-to-using-filters/

•

You can do it: http://wp.tutsplus.com/tutorials/
plugins/writing-extensible-plugins-with-actionsand-filters/
Properly enqueue scripts
and styles
•

http://wpcandy.com/teaches/how-to-load-scripts-inwordpress-themes/

•

http://wp.tutsplus.com/tutorials/the-ins-and-outs-of-theenqueue-script-for-wordpress-themes-and-plugins/

•

Register, then enqueue

•

Only enqueue when you need to
•

•

Conditionals in the enqueue function, or right in the
function or template

Load in the footer most of the time
Theme setup function

•

http://justintadlock.com/archives/2010/12/30/
wordpress-theme-function-files

•

Because priorities, that’s why.
Loading files

•

http://justintadlock.com/archives/2010/11/17/
how-to-load-files-within-wordpress-themes
WordPress URLs
•

The URL tells WordPress what to look up. Always
remember this.

•

http://wp.tutsplus.com/tutorials/creative-coding/
the-rewrite-api-the-basics/
Loops
•

The default WordPress loop

•

WP_Query: http://codex.wordpress.org/Class_Reference/WP_Query
•

Best. Presentation. Ever. http://wordpress.tv/2013/03/15/andrew-nacinwp_query-wordpress-in-depth/

•

wp_reset_postdata() vs wp_reset_query() http://www.poststat.us/properlyreset-wordpress-query/

•

update_post_meta_cache & update_post_term_cache

•

get_posts

•

pre_get_posts hook http://codex.wordpress.org/Plugin_API/Action_Reference/
pre_get_posts

•

If you use query_posts(), go home.
Post Meta
•

get_post_custom() versus lots of get_post_meta().

•

Check for existence before output to prevent empty markup.

•

Classes / Tools.
•

Advanced Custom Fields

•

Pods

•

CMB

•

Core??? http://make.wordpress.org/core/tag/
metamorphosis/
Design
Responsive Design
•

Either do it right, or don’t do it.

•

<meta name=“viewport” content=“width=device-width, initialscale=1”>

•

Separate stylesheet? It depends.
•

If not mobile first or using a PreProcessor, and building a parent
them, then yes.

•

Consider navigation http://www.poststat.us/wordpress-responsivenavigation-options/

•

Consider what *could* go into different areas

•

Breakpoints are arbitrary.
* { box-sizing: Border-box }

•

FTW
•

http://www.paulirish.com/2012/box-sizingborder-box-ftw/
SVG vs Icon Fonts vs
Fallback PNGs.

•

Depends on the browser support required
•

http://caniuse.com/
General Principles
Let plugins take care of what
they are good at
•

Breadcrumbs? Pagination? Depends on the
project.

•

SEO? Let it go.

•

Analyze each situation.
Functions.php is not a
landfill

•

Have either a site-specific plugin or reusable
functionality plugins. Or both.
Stay DRY

•

Don’t Repeat Yourself
Use things WordPress gives
you
•

Customizer

•

Settings API

•

Etc.
Test yourself!
•

Always have wp_debug on.

•

WP Test http://wptest.io/

•

Monster Widget http://wordpress.org/plugins/monsterwidget/

•

Use the Developer plugin http://wordpress.org/plugins/
developer/

•

Monitor queries http://wordpress.org/plugins/query-monitor/

•

Chrome Inspector (Waterfall)
Browser Support

•

Keep browser support in mind, always.
•

http://www.poststat.us/explicit-browsersupport/
Learn from the greats
•

Nobody *really* starts from scratch.
•

_s https://github.com/automattic/_s

•

Stargazer https://github.com/justintadlock/
stargazer

•

Default Themes
Tools
Tools
•

CodeKit
•
•

Minifies files
Checks for errors in CSS and JS

•
•
•

Live updates locally!
Compiles Preprocessors

PreProcessors
•

Sass
•

Compass http://compass-style.org/

•

Bourbon http://bourbon.io
•

•
•

Neat (Yeah, for real). http://neat.bourbon.io/

LESS

Frameworks (UI)
•

Foundation by Zurb http://foundation.zurb.com/

•

Twitter Bootstrap http://getbootstrap.com/
Tools
•

Handy JS
•

Flexslider flexslider.woothemes.com

•

CarouFredSel http://dev7studios.com/plugins/caroufredsel

•

Validation
•
•

•
•

http://jqueryvalidation.org/validate/
yoast.com/checkout-field-validation/

Use stuff WP ships with!

Icon Fonts
•
•

Genericons

•
•

Dashicons

Font Awesome

Typefaces
•

Typography.com

•

Typekit.com

•

google.com/fonts
Tools
•

Version control / Deployment
•
•

Versions (SVN)

•
•

Beanstalk

Tower (Git)

Working Locally
•

VVV

•

Mamp Pro

•

ServerPress

•

VIP Quickstart
Tools
•

Handy sites / Code Snippets
•

http://codex.wordpress.org/Template_Tags

•

http://queryposts.com/

•

http://adambrown.info/p/wp_hooks

•

http://www.billerickson.net/code/

•

http://generatewp.com/

•

http://themergency.com/generators/

•

http://wordpress.stackexchange.com/

•

http://spritecow.com
WordPress Theming Best Practices
for Client-Centric Web Development

Brian Krogsgard - WordSesh 2!

!
Post Status | poststat.us |@post_status

More Related Content

What's hot

WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsJoe Querin
 
Child Themes and CSS in WordPress
Child Themes and CSS in WordPressChild Themes and CSS in WordPress
Child Themes and CSS in WordPressMatthew Vaccaro
 
How to make WordPress your friend
How to make WordPress your friendHow to make WordPress your friend
How to make WordPress your friendKerch McConlogue
 
WordPress Beginners Workshop
WordPress Beginners WorkshopWordPress Beginners Workshop
WordPress Beginners WorkshopThe Toolbox, Inc.
 
The web standards gentleman: a matter of (evolving) standards)
The web standards gentleman: a matter of (evolving) standards)The web standards gentleman: a matter of (evolving) standards)
The web standards gentleman: a matter of (evolving) standards)Chris Mills
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your websitehernanibf
 
Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Jamie Oastler
 
Drupal content editor flexibility
Drupal content editor flexibilityDrupal content editor flexibility
Drupal content editor flexibilityhernanibf
 
WCBos13 intermediate workshop
WCBos13 intermediate workshopWCBos13 intermediate workshop
WCBos13 intermediate workshopBoston WordPress
 
Bootstrap Framework and Drupal
Bootstrap Framework and DrupalBootstrap Framework and Drupal
Bootstrap Framework and DrupalJim Birch
 
Creating Web Templates for SharePoint 2010
Creating Web Templates for SharePoint 2010Creating Web Templates for SharePoint 2010
Creating Web Templates for SharePoint 2010Mark Collins
 
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreCreating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreSuzanne Dergacheva
 
My site is slow
My site is slowMy site is slow
My site is slowhernanibf
 
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DayCreating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DaySuzanne Dergacheva
 
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon DublinCreating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon DublinSuzanne Dergacheva
 

What's hot (18)

WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
 
Child Themes and CSS in WordPress
Child Themes and CSS in WordPressChild Themes and CSS in WordPress
Child Themes and CSS in WordPress
 
How to make WordPress your friend
How to make WordPress your friendHow to make WordPress your friend
How to make WordPress your friend
 
WordPress Beginners Workshop
WordPress Beginners WorkshopWordPress Beginners Workshop
WordPress Beginners Workshop
 
The web standards gentleman: a matter of (evolving) standards)
The web standards gentleman: a matter of (evolving) standards)The web standards gentleman: a matter of (evolving) standards)
The web standards gentleman: a matter of (evolving) standards)
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your website
 
Learn Bootstrap 4
Learn Bootstrap 4Learn Bootstrap 4
Learn Bootstrap 4
 
Bootstrap [part 1]
Bootstrap [part 1]Bootstrap [part 1]
Bootstrap [part 1]
 
Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08Wordpress Beyond A Blog Word Camp Toronto08
Wordpress Beyond A Blog Word Camp Toronto08
 
Drupal content editor flexibility
Drupal content editor flexibilityDrupal content editor flexibility
Drupal content editor flexibility
 
Bootstrap 4 Alpha 3
Bootstrap 4 Alpha 3Bootstrap 4 Alpha 3
Bootstrap 4 Alpha 3
 
WCBos13 intermediate workshop
WCBos13 intermediate workshopWCBos13 intermediate workshop
WCBos13 intermediate workshop
 
Bootstrap Framework and Drupal
Bootstrap Framework and DrupalBootstrap Framework and Drupal
Bootstrap Framework and Drupal
 
Creating Web Templates for SharePoint 2010
Creating Web Templates for SharePoint 2010Creating Web Templates for SharePoint 2010
Creating Web Templates for SharePoint 2010
 
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreCreating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
 
My site is slow
My site is slowMy site is slow
My site is slow
 
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DayCreating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
 
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon DublinCreating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
 

Viewers also liked

I made my blog my business
I made my blog my businessI made my blog my business
I made my blog my businessBrian Krogsgard
 
LT データ可視化とd3.js js_cafe_20130908_otanet
LT データ可視化とd3.js js_cafe_20130908_otanetLT データ可視化とd3.js js_cafe_20130908_otanet
LT データ可視化とd3.js js_cafe_20130908_otanet博三 太田
 
Chuong 03. nhap du lieu
Chuong 03.  nhap du lieuChuong 03.  nhap du lieu
Chuong 03. nhap du lieuThuy Thanh
 
Projekt E-građani: Smjernice za izradu središnjeg državnog portala - GOV.HR
Projekt E-građani: Smjernice za izradu središnjeg državnog portala - GOV.HRProjekt E-građani: Smjernice za izradu središnjeg državnog portala - GOV.HR
Projekt E-građani: Smjernice za izradu središnjeg državnog portala - GOV.HRTomislav Korman
 
Appeared in new york times yesterday
Appeared in new york times yesterdayAppeared in new york times yesterday
Appeared in new york times yesterdayAbhishek Saha
 
Online contact process coaching v2 by infinite prospects
Online contact process coaching v2 by infinite prospectsOnline contact process coaching v2 by infinite prospects
Online contact process coaching v2 by infinite prospectsAdam Ross
 
iDentity: Negotiating constructions of self in the digital space
iDentity: Negotiating constructions of self in the digital spaceiDentity: Negotiating constructions of self in the digital space
iDentity: Negotiating constructions of self in the digital spaceashetler
 
Speech enhanced gesture based navigation for Google Maps
Speech enhanced gesture based navigation for Google MapsSpeech enhanced gesture based navigation for Google Maps
Speech enhanced gesture based navigation for Google MapsHimanshu Bansal
 
Paisley Engaging young professionals in the agri food sector - strategies, le...
Paisley Engaging young professionals in the agri food sector - strategies, le...Paisley Engaging young professionals in the agri food sector - strategies, le...
Paisley Engaging young professionals in the agri food sector - strategies, le...futureagricultures
 
Acids & Bases Day 1
Acids & Bases   Day 1Acids & Bases   Day 1
Acids & Bases Day 1jmori1
 
CSR Skills: What you need and why
CSR Skills: What you need and whyCSR Skills: What you need and why
CSR Skills: What you need and whyWayne Dunn
 
Kudavi 2.19.2016
Kudavi 2.19.2016Kudavi 2.19.2016
Kudavi 2.19.2016Tom Currier
 
Vancouver executive briefing seminar by csr training institute
Vancouver executive briefing seminar by csr training instituteVancouver executive briefing seminar by csr training institute
Vancouver executive briefing seminar by csr training instituteWayne Dunn
 
Ig2 assignment brief_updated_27.04.12
Ig2 assignment brief_updated_27.04.12Ig2 assignment brief_updated_27.04.12
Ig2 assignment brief_updated_27.04.12FirstClassProductions
 
Aef4 week 2
Aef4 week 2Aef4 week 2
Aef4 week 2Les Davy
 
Что делать с деструкторами?
Что делать с деструкторами?Что делать с деструкторами?
Что делать с деструкторами?Dinar Ibragimov
 

Viewers also liked (20)

I made my blog my business
I made my blog my businessI made my blog my business
I made my blog my business
 
Corrider annotation
Corrider annotationCorrider annotation
Corrider annotation
 
Full turkey cycle17 2013
Full turkey cycle17 2013Full turkey cycle17 2013
Full turkey cycle17 2013
 
LT データ可視化とd3.js js_cafe_20130908_otanet
LT データ可視化とd3.js js_cafe_20130908_otanetLT データ可視化とd3.js js_cafe_20130908_otanet
LT データ可視化とd3.js js_cafe_20130908_otanet
 
Chuong 03. nhap du lieu
Chuong 03.  nhap du lieuChuong 03.  nhap du lieu
Chuong 03. nhap du lieu
 
Projekt E-građani: Smjernice za izradu središnjeg državnog portala - GOV.HR
Projekt E-građani: Smjernice za izradu središnjeg državnog portala - GOV.HRProjekt E-građani: Smjernice za izradu središnjeg državnog portala - GOV.HR
Projekt E-građani: Smjernice za izradu središnjeg državnog portala - GOV.HR
 
Appeared in new york times yesterday
Appeared in new york times yesterdayAppeared in new york times yesterday
Appeared in new york times yesterday
 
Online contact process coaching v2 by infinite prospects
Online contact process coaching v2 by infinite prospectsOnline contact process coaching v2 by infinite prospects
Online contact process coaching v2 by infinite prospects
 
iDentity: Negotiating constructions of self in the digital space
iDentity: Negotiating constructions of self in the digital spaceiDentity: Negotiating constructions of self in the digital space
iDentity: Negotiating constructions of self in the digital space
 
Speech enhanced gesture based navigation for Google Maps
Speech enhanced gesture based navigation for Google MapsSpeech enhanced gesture based navigation for Google Maps
Speech enhanced gesture based navigation for Google Maps
 
Paisley Engaging young professionals in the agri food sector - strategies, le...
Paisley Engaging young professionals in the agri food sector - strategies, le...Paisley Engaging young professionals in the agri food sector - strategies, le...
Paisley Engaging young professionals in the agri food sector - strategies, le...
 
Acids & Bases Day 1
Acids & Bases   Day 1Acids & Bases   Day 1
Acids & Bases Day 1
 
CSR Skills: What you need and why
CSR Skills: What you need and whyCSR Skills: What you need and why
CSR Skills: What you need and why
 
Kudavi 2.19.2016
Kudavi 2.19.2016Kudavi 2.19.2016
Kudavi 2.19.2016
 
Ds105 2013 ef_ep_a
Ds105 2013 ef_ep_aDs105 2013 ef_ep_a
Ds105 2013 ef_ep_a
 
prehistoric/ancient
prehistoric/ancientprehistoric/ancient
prehistoric/ancient
 
Vancouver executive briefing seminar by csr training institute
Vancouver executive briefing seminar by csr training instituteVancouver executive briefing seminar by csr training institute
Vancouver executive briefing seminar by csr training institute
 
Ig2 assignment brief_updated_27.04.12
Ig2 assignment brief_updated_27.04.12Ig2 assignment brief_updated_27.04.12
Ig2 assignment brief_updated_27.04.12
 
Aef4 week 2
Aef4 week 2Aef4 week 2
Aef4 week 2
 
Что делать с деструкторами?
Что делать с деструкторами?Что делать с деструкторами?
Что делать с деструкторами?
 

Similar to WordPress Theming Best Practices

How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
WordPress Intermediate Workshop
WordPress Intermediate WorkshopWordPress Intermediate Workshop
WordPress Intermediate WorkshopThe Toolbox, Inc.
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform AppsFITC
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflowPeter Kaizer
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, SuccessfullySauce Labs
 
Rapid WordPress theme development
Rapid WordPress theme developmentRapid WordPress theme development
Rapid WordPress theme developmentJonny Allbut
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPressTaylor Lovett
 
Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Morten Rand-Hendriksen
 
Node.js 101
 Node.js 101 Node.js 101
Node.js 101FITC
 
WordPress Themes and Plugins
WordPress Themes and PluginsWordPress Themes and Plugins
WordPress Themes and Pluginssuperann
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Dutyreedmaniac
 
FITC - Bootstrap Unleashed
FITC - Bootstrap UnleashedFITC - Bootstrap Unleashed
FITC - Bootstrap UnleashedRami Sayar
 
BP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesBP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesAlfresco Software
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyLeslie Doherty
 

Similar to WordPress Theming Best Practices (20)

Miami2015
Miami2015Miami2015
Miami2015
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Joomla! theming
Joomla! themingJoomla! theming
Joomla! theming
 
WordPress Intermediate Workshop
WordPress Intermediate WorkshopWordPress Intermediate Workshop
WordPress Intermediate Workshop
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform Apps
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, Successfully
 
Rapid WordPress theme development
Rapid WordPress theme developmentRapid WordPress theme development
Rapid WordPress theme development
 
The WordPress Way
The WordPress WayThe WordPress Way
The WordPress Way
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0
 
Node.js 101
 Node.js 101 Node.js 101
Node.js 101
 
WordPress Themes and Plugins
WordPress Themes and PluginsWordPress Themes and Plugins
WordPress Themes and Plugins
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
presentation
presentationpresentation
presentation
 
FITC - Bootstrap Unleashed
FITC - Bootstrap UnleashedFITC - Bootstrap Unleashed
FITC - Bootstrap Unleashed
 
BP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesBP-9 Share Customization Best Practices
BP-9 Share Customization Best Practices
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
presentation
presentationpresentation
presentation
 

More from Brian Krogsgard

From Blog to Business -- Building Membership Websites with WordPress
From Blog to Business -- Building Membership Websites with WordPressFrom Blog to Business -- Building Membership Websites with WordPress
From Blog to Business -- Building Membership Websites with WordPressBrian Krogsgard
 
Practical eCommerce with WooCommerce
Practical eCommerce with WooCommercePractical eCommerce with WooCommerce
Practical eCommerce with WooCommerceBrian Krogsgard
 
The State of WordPress Business
The State of WordPress BusinessThe State of WordPress Business
The State of WordPress BusinessBrian Krogsgard
 
Why we publish -- WordCamp Birmingham 2014
Why we publish -- WordCamp Birmingham 2014Why we publish -- WordCamp Birmingham 2014
Why we publish -- WordCamp Birmingham 2014Brian Krogsgard
 
How Blogging Kickstarted My Career
How Blogging Kickstarted My CareerHow Blogging Kickstarted My Career
How Blogging Kickstarted My CareerBrian Krogsgard
 
Going For It: How to Become a Respected WordPress Developer
Going For It: How to Become a Respected WordPress DeveloperGoing For It: How to Become a Respected WordPress Developer
Going For It: How to Become a Respected WordPress DeveloperBrian Krogsgard
 
WordPress for Beginners | WordCamp Birmingham
WordPress for Beginners | WordCamp BirminghamWordPress for Beginners | WordCamp Birmingham
WordPress for Beginners | WordCamp BirminghamBrian Krogsgard
 
Wp bham 2011 08 01 meetup on wp 3.2
Wp bham 2011 08 01 meetup on wp 3.2Wp bham 2011 08 01 meetup on wp 3.2
Wp bham 2011 08 01 meetup on wp 3.2Brian Krogsgard
 

More from Brian Krogsgard (8)

From Blog to Business -- Building Membership Websites with WordPress
From Blog to Business -- Building Membership Websites with WordPressFrom Blog to Business -- Building Membership Websites with WordPress
From Blog to Business -- Building Membership Websites with WordPress
 
Practical eCommerce with WooCommerce
Practical eCommerce with WooCommercePractical eCommerce with WooCommerce
Practical eCommerce with WooCommerce
 
The State of WordPress Business
The State of WordPress BusinessThe State of WordPress Business
The State of WordPress Business
 
Why we publish -- WordCamp Birmingham 2014
Why we publish -- WordCamp Birmingham 2014Why we publish -- WordCamp Birmingham 2014
Why we publish -- WordCamp Birmingham 2014
 
How Blogging Kickstarted My Career
How Blogging Kickstarted My CareerHow Blogging Kickstarted My Career
How Blogging Kickstarted My Career
 
Going For It: How to Become a Respected WordPress Developer
Going For It: How to Become a Respected WordPress DeveloperGoing For It: How to Become a Respected WordPress Developer
Going For It: How to Become a Respected WordPress Developer
 
WordPress for Beginners | WordCamp Birmingham
WordPress for Beginners | WordCamp BirminghamWordPress for Beginners | WordCamp Birmingham
WordPress for Beginners | WordCamp Birmingham
 
Wp bham 2011 08 01 meetup on wp 3.2
Wp bham 2011 08 01 meetup on wp 3.2Wp bham 2011 08 01 meetup on wp 3.2
Wp bham 2011 08 01 meetup on wp 3.2
 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 

Recently uploaded (20)

The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 

WordPress Theming Best Practices

  • 1. WordPress Theming Best Practices for Client-Centric Web Development Brian Krogsgard - WordSesh 2! ! Post Status | poststat.us |@post_status
  • 3. Assets • CSS / JS / Images / fonts • Sprites, minified files
  • 5. Template Parts • Naming conventions and organization. • • • Prefix page templates “page-about-template.php” or nest them in a “page-templates” folder. For partial templates, use logical and consistent conventions. Lean toward smaller templates. • • Are you repeating yourself? Make it a template part. Give good and thorough comment blocks at the top of templates, even partial ones
  • 8. Follow the guides • Seriously, take the time to properly format your code. • http://codex.wordpress.org/ WordPress_Coding_Standards
  • 9. Entering and exiting PHP • In templates versus functions / operational code • When in PHP, stay in PHP
  • 10. Curly brackets versus alternative syntax for control structures • http://php.net/manual/en/controlstructures.alternative-syntax.php • http://pippinsplugins.com/please-do-not-usecurly-brackets-in-template-files/ • http://tommcfarlin.com/commenting-code-blocks/
  • 12. Alignment • Tabs for nesting, spaces for alignment.
  • 13. Code
  • 14. Hook Order • Core Load http://www.rarst.net/script/wordpresscore-load/ • Wowza hooks http://codex.wordpress.org/ Plugin_API/Action_Reference • Special shoutout to template_redirect (conditionals)
  • 15. Action and filters • Make your parent themes filterable! • Intro: http://pippinsplugins.com/a-quickintroduction-to-using-filters/ • You can do it: http://wp.tutsplus.com/tutorials/ plugins/writing-extensible-plugins-with-actionsand-filters/
  • 16. Properly enqueue scripts and styles • http://wpcandy.com/teaches/how-to-load-scripts-inwordpress-themes/ • http://wp.tutsplus.com/tutorials/the-ins-and-outs-of-theenqueue-script-for-wordpress-themes-and-plugins/ • Register, then enqueue • Only enqueue when you need to • • Conditionals in the enqueue function, or right in the function or template Load in the footer most of the time
  • 19. WordPress URLs • The URL tells WordPress what to look up. Always remember this. • http://wp.tutsplus.com/tutorials/creative-coding/ the-rewrite-api-the-basics/
  • 20. Loops • The default WordPress loop • WP_Query: http://codex.wordpress.org/Class_Reference/WP_Query • Best. Presentation. Ever. http://wordpress.tv/2013/03/15/andrew-nacinwp_query-wordpress-in-depth/ • wp_reset_postdata() vs wp_reset_query() http://www.poststat.us/properlyreset-wordpress-query/ • update_post_meta_cache & update_post_term_cache • get_posts • pre_get_posts hook http://codex.wordpress.org/Plugin_API/Action_Reference/ pre_get_posts • If you use query_posts(), go home.
  • 21. Post Meta • get_post_custom() versus lots of get_post_meta(). • Check for existence before output to prevent empty markup. • Classes / Tools. • Advanced Custom Fields • Pods • CMB • Core??? http://make.wordpress.org/core/tag/ metamorphosis/
  • 23. Responsive Design • Either do it right, or don’t do it. • <meta name=“viewport” content=“width=device-width, initialscale=1”> • Separate stylesheet? It depends. • If not mobile first or using a PreProcessor, and building a parent them, then yes. • Consider navigation http://www.poststat.us/wordpress-responsivenavigation-options/ • Consider what *could* go into different areas • Breakpoints are arbitrary.
  • 24. * { box-sizing: Border-box } • FTW • http://www.paulirish.com/2012/box-sizingborder-box-ftw/
  • 25. SVG vs Icon Fonts vs Fallback PNGs. • Depends on the browser support required • http://caniuse.com/
  • 27. Let plugins take care of what they are good at • Breadcrumbs? Pagination? Depends on the project. • SEO? Let it go. • Analyze each situation.
  • 28. Functions.php is not a landfill • Have either a site-specific plugin or reusable functionality plugins. Or both.
  • 30. Use things WordPress gives you • Customizer • Settings API • Etc.
  • 31. Test yourself! • Always have wp_debug on. • WP Test http://wptest.io/ • Monster Widget http://wordpress.org/plugins/monsterwidget/ • Use the Developer plugin http://wordpress.org/plugins/ developer/ • Monitor queries http://wordpress.org/plugins/query-monitor/ • Chrome Inspector (Waterfall)
  • 32. Browser Support • Keep browser support in mind, always. • http://www.poststat.us/explicit-browsersupport/
  • 33. Learn from the greats • Nobody *really* starts from scratch. • _s https://github.com/automattic/_s • Stargazer https://github.com/justintadlock/ stargazer • Default Themes
  • 34. Tools
  • 35. Tools • CodeKit • • Minifies files Checks for errors in CSS and JS • • • Live updates locally! Compiles Preprocessors PreProcessors • Sass • Compass http://compass-style.org/ • Bourbon http://bourbon.io • • • Neat (Yeah, for real). http://neat.bourbon.io/ LESS Frameworks (UI) • Foundation by Zurb http://foundation.zurb.com/ • Twitter Bootstrap http://getbootstrap.com/
  • 36. Tools • Handy JS • Flexslider flexslider.woothemes.com • CarouFredSel http://dev7studios.com/plugins/caroufredsel • Validation • • • • http://jqueryvalidation.org/validate/ yoast.com/checkout-field-validation/ Use stuff WP ships with! Icon Fonts • • Genericons • • Dashicons Font Awesome Typefaces • Typography.com • Typekit.com • google.com/fonts
  • 37. Tools • Version control / Deployment • • Versions (SVN) • • Beanstalk Tower (Git) Working Locally • VVV • Mamp Pro • ServerPress • VIP Quickstart
  • 38. Tools • Handy sites / Code Snippets • http://codex.wordpress.org/Template_Tags • http://queryposts.com/ • http://adambrown.info/p/wp_hooks • http://www.billerickson.net/code/ • http://generatewp.com/ • http://themergency.com/generators/ • http://wordpress.stackexchange.com/ • http://spritecow.com
  • 39. WordPress Theming Best Practices for Client-Centric Web Development Brian Krogsgard - WordSesh 2! ! Post Status | poststat.us |@post_status