Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

WordCamp Birmingham 2015 - Theme building tricks of the trade

2,174 views

Published on

I’ve been building WordPress themes since 2005 and have developed a-lot of useful little tricks along the way. I’ll be sharing a handful of my best techniques to help you work with WordPress and build themes like a pro!

Published in: Technology
  • Login to see the comments

  • Be the first to like this

WordCamp Birmingham 2015 - Theme building tricks of the trade

  1. 1. http://jonnya.net@jonnyauk http://wider.co.uk Theme building tricks of the trade Jonny Allbut - Creative Director
  2. 2. http://jonnya.net@jonnyauk http://wider.co.uk ‣ Working with WordPress since 2005. ‣ Involved in WPUK group & co-organiser of Birmingham WordPress user group & WordCamp Birmingham. ‣ Likes to share: ‣ Wonderflux - free GPL theme framework
 http://wonderflux.com ‣ WP-CMS Post Control - control post editing capabilities
 http://wordpress.org/plugins/wp-cms-post-control Howdy!
  3. 3. http://jonnya.net@jonnyauk http://wider.co.uk ‣ wp-config.php define( 'WP_DEBUG', false ); Day 1 - debug on!
  4. 4. http://jonnya.net@jonnyauk http://wider.co.uk ‣ wp-config.php define( 'SCRIPT_DEBUG', true ); No minified core CSS/scripts
  5. 5. http://jonnya.net@jonnyauk http://wider.co.uk ‣ wp-config.php define( 'DISALLOW_FILE_EDIT', true ); No editing files in admin
  6. 6. http://jonnya.net@jonnyauk http://wider.co.uk ‣ Make your debugging easier to read ‣ Interrogate what data you are working with ‣http://wider.io/brum-debug Turbo debug function
  7. 7. http://jonnya.net@jonnyauk http://wider.co.uk $my_value = 1; printf( _n( 'Counting just 1 time', 'Counting %s times, whoot!', $my_value, 'mytheme' ), $my_value ); ‣http://wider.io/brum-num Formatting string of text
  8. 8. http://jonnya.net@jonnyauk http://wider.co.uk function mywfx_archive_posts_pp($query) { if ( !is_admin() && $query->is_main_query() ) { $query->set( 'posts_per_page', 5 ); return $query; } } add_action( 'pre_get_posts', 'mywfx_archive_posts_pp', 1 ); Interacting with main query
  9. 9. http://jonnya.net@jonnyauk http://wider.co.uk function mywfx_archive_order_by_title($query) { if ( !is_admin() && $query->is_main_query() ) { if ( is_post_type_archive( ‘kitty’ ) { $query->set( 'orderby', 'title' ); $query->set( 'order', 'ASC' ); } return $query; } } add_action( 'pre_get_posts', 'mywfx_archive_order_by_title', 1 ); ‣http://wider.io/brum-posts Interacting with main query
  10. 10. http://jonnya.net@jonnyauk http://wider.co.uk function mywfx_empty_menu() { $page_data = wp_list_pages(array( 'post_type' => 'page', 'post_status' => 'publish', 'echo' => 0, 'number' => 3, 'title_li' => '' )); echo '<ul class="menu">'; echo $page_data; echo ( current_user_can( 'manage_options' ) ) ? '<li>' . '<a href="' . admin_url( 'nav- menus.php' ) . '">' . 'Edit this menu' . '</a>' . '</li>' : ''; echo '</ul>'; } ‣http://wider.io/brum-menu Empty menus be gone!

×