To build a WordPress Theme: Wordcamp Denmark 2014
- 4. Thank you!
Surftown, One.com, Peytz & Co, IT-Kompetence
Founders House, KraftWerket
All speakers & attendees
Annette, Jes, Lisa, Patrick, Martin, Nicolas, Thor, Flyver
- 10. What is a theme? (conceptually)
Fundamentally, the WordPress Theme system
is a way to "skin" your weblog. Yet, it is more
than just a "skin." Skinning your site implies
that only the design is changed.
“
“WordPress Codex
- 11. What is a theme? (conceptually)
WordPress Themes can provide much more
control over the look and presentation of the
material on your website.
“
“
WordPress Codex
- 12. What is a theme? (conceptually)
Presentation
- organisation of information (HTML, js)
Skin
- look & feel across devices (CSS, js)
- 13. What is a theme? (technically)
● It’s a folder with HTML, PHP, CSS and js
- 17. What is a theme? (technically)
functions.php
templates, etc.
Browser
requests... includes...
Hooks,
functions,
HTML
HTML
- 18. What is a theme? (technically)
Browser| | | | | | | | | | | | | | | | | | | | | | | |
Hooks
PLUGIN
S
THEM
E
- 20. Plugins and Themes
The theme and plugin architecture is very
loose.
Browser| | | | | | | | | | | | | | | | | | | | | | | |
Hooks
PLUGIN
S
THEM
E
- 23. ...often it’s actually like this...
Functionality
- new post types, integrations, tools (PHP)
Presentation
- organisation of information (HTML, js)
Skin
- look & feel across devices (CSS, js)
- 29. Maintenance is harder
● Cause and effect
● OMG! Functions.php had 10,000 lines
● Can’t remember what’s there
● Can’t just switch off features without
breaking stuff
● Imagine having 50 sites like this
- 30. Upgrades are scarier
● More tricky to find problems
● Dependencies get messy
● Built-in theme features get left as is, while
plugins get updated
- 31. Performance can suffer
● Too many HTTP requests
● Multiple loading of the same or similar
scripts
● Bloated css, due to a lot of overwriting
- 32. Others don’t get it
● Harder for others to understand what there is
and where it is
● More training & documentation needed
- 34. In the theme
● Think about the architecture
● Break functions.php up
o theme features, hooks, widgets, admin
● Check performance & HTTP requests on
plugin activation
● Compress or unhook little css and js files
- 36. 01 function myplugin_review_template() {
02 // Target only the single review page
03 if ( !is_single() || get_post_type() != 'review' ) {
04 return;
05 }
06
07 // If it’s in the theme, return it, else use the plugin version
08 if ( $file = locate_template( array( 'single-review.php' ) ) ) {
09 return $file;
10 } else {
11 return plugin_dir_path( __FILE__ ) . '/templates/single-review.php';
12 }
13 }
14 add_filter( 'template_include', 'myplugin_review_template', 1 );
- 40. Photo Credits (all CC)
John Ward - https://www.flickr.com/photos/spadgy/313250749/
Thor Kristiansen (uploaded to the meetup group)
Ed Shipl - https://www.flickr.com/photos/eschipul/6224599604/
slworking2 - https://www.flickr.com/photos/slworking/6173188780
Maciej Lewandowski - https://www.flickr.com/photos/macieklew/454570443
@jamesbonham
jamesbonham.com
Remember the jobs @Peytz
...and see you at the happiness bar!
Editor's Notes
- full-service web bureau
awesome jobs
come work with us
learn a crazy amount
- 5 years
- Concept
Technically - files, code
- weblog
- Examples:
Presentation: Positioning of elements - where are the widgets? How an element is displayed. pagination - next link, or a page numbers. Menu structure. Infinite scroll?
Skin: Color, typography, mood, whitespace.
- In a bit: How this fits into the wordpress architecture
- Template Hierarchy
- You look bored
- Both can set up new post types.
Both can call external libraries.
Both can call and include css and js files
Both can set custom image sizes
- Copy and paste all kinds of stuff into functions.php
Mixture of business logic and presentation.
- Often find this in purchased themes. All kinds of features are built into themes… portfolio post types, meta data
- Theme that is responsible for the skin and presentation
Mix of 3rd party and custom plugins
- without extra stylesheets etc.
- most suitable for pro sites with high traffic
Takes a lot of time and skill
- Good outcome, most typical for devs
Custom theme, some 3rd party plugins
Takes time
- Typical site built with “feature-packed” themes
Built into theme (post types - portfolio, employees, social media & SEO, backend builder tools)
Large (or large number of) 3rd party plugins
Fastest to build
Problematic
- “feature-packed” themes & very many plugins that interfere with skin
- Is it the theme, a plugin or wordpress? Or two?
Everything is in everything. Which to fix?
Lazy with heavy php in themes - doesn’t get updated - e.g. external libraries (FB API)
- Plugins add css files, js files
- - Is it new functionality, that would work as a plugin? (or can already get?) - e.g. tool to find nearest store
- Less friction
- If little functionality is in the theme, functions file won’t be that long
- But most of all...