Things I Wish I Had Known Before Developing a WordPress Theme Konstantin Kovshenin Automattic
Jan 28, 2015
Things I Wish I Had Known Before Developing a WordPress ThemeKonstantin KovsheninAutomattic
K
Publish
Expound
Get Organized
WordPress Coding Standards
wp_enqueue_script()wp_enqueue_style()
Don’t Bundle Scripts Which are Available in
WordPress
Use Subdirectories
get_template_part()
get_template_part( 'content', get_post_format() );
query_posts()
Stop query_posts
query_posts() is bad and you should never use it
“”
— Andrew Nacin, WordPress Lead Developer
pre_get_posts
new WP_Query()get_posts()
Theme Options
Weaver
Decisions, not Options
Feature Bloat and Plugin Territory
Portfolio Post Type
Implement CoreFeatures
add_editor_style()
Localize Your Theme
Default Widget Styles
Monster Widget
if ( function_exists( 'register_sidebar' ) ) {
dynamic_sidebar()is_active_sidebar()
Be a Good Parent (Theme)
Simple Structure
!important
BackwardsCompatibility
Pluggable Functions
if ( ! function_exists( 'foo' ) ):function foo() { ...}endif;
Actions and Filters
Listen
Be a Good Child(Theme)
Speed is Everything
Optimize Your Images
smushitoptipng
pngcrushjpegtran
Cache ComplexQueries
function _s_categorized_blog() { $c = get_transient( 'cool_cats' ); if ( false === $c ) { $c = count( get_categories( … ) ); set_transient( 'cool_cats', $c ); } return $c > 1;}
10x Faster!
get_option( 'sticky_posts' )
Benchmark
Security
wp_kses()esc_html()esc_attr()esc_url()
...
Don’t Use TimThumb
set_post_thumbnail_size()add_image_size()
WordPress.org Themes Directory
make.wordpress.org/themes
What Makes a Good WordPress Theme?
Great DesignEase of UseSimple StructureFlexibilitySpeedReliabilitySecurity
Konstantin Kovsheninkovshenin.com/wcsf2013