Jared Atchison discusses common mistakes made when developing WordPress themes, including improperly adding JavaScript, using the packaged jQuery incorrectly, including files the wrong way, using problematic permalink structures, and not building themes on proven frameworks. He provides tips for troubleshooting issues, getting help, and staying informed as a WordPress developer.
5. Adding JavaScript to themes 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch wp-content/themes/YourTheme/header.php
6.
7.
8. Adding JavaScript to themes 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
9. WP packaged jQuery WordPress ships with jQuery (1.4.2) /wp-includes/js/jquery/jquery.js wp_enqueue_script(‘jquery’); Most often replaced with copy from Google CDN https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
10. WP packaged jQuery WHY REMOVE? Wants/needs the newest version (e.g. 1.4.4) Wants to be on CDN (content delivery network) “decreased latency, increased parallelism, and better caching.” http://encosia.com/2008/12/10/3-reasons-why-you-should-let-google-host-jquery-for-you/ WTFBBQ!! jQuery.noConflict(); - no conflict mode http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers http://docs.jquery.com/Using_jQuery_with_Other_Libraries Doesn’t understand/use wp_enqueue_script(); 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
11. WP packaged jQuery WHY NOT REMOVE? Adding JS the wrong way (first point) can cause chaos. Duplicate jQuery includes, OH NOES! ThemeForest.net … *face palm* Public CDN not always “be all and end all”. Relying on Google Look into W3 Total Cache Cross library compatibly often lost (no conflict) 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
12. WP packaged jQuery IF NEEDED, DO IT CORRECTLY :) 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Load_a_default_WordPress_script_from_a_non-default_location
13. WP packaged jQuery WORKING WITH NO CONFLICT Virtually all popular jQuery scripts work in NC mode Yours can too! Use long-hand document ready… 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
14. Including files Can be done many different ways (successfully). Certain methods for certain situations include(); require_once(); get_header(); get_sidebar(); and get_footer() get_template_part(); Since 3.0 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
15. Using Permalinks WordPress gives great permalink control You can do almost anything – but should you? ZOMG! BUT SEO!!!!! Lies. http://www.weberz.com/blog/2009/06/seo-experts-give-wrong-advice-wordpress-permalinks Do not start permalinks with %category% or %postname% Pages + non-numerical starting permalinks = tons extra rules Custom post types excluded 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
16. Using Permalinks %year% – The year of the post, four digits, for example 2004 %monthnum% – Month of the year, for example 05 %day% – Day of the month, for example 28 %hour% – Hour of the day, for example 15 %minute% – Minute of the hour, for example 43 %second% – Second of the minute, for example 33 %post_id% – The unique ID # of the post, for example 423 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch “Use a permalink structure that does not start with a text based variable. By doing this you will drastically reduce your risk of the problems listed above. Here is a list of variables you can use that are not text based:” Further Reading: http://ottopress.com/2010/category-in-permalinks-considered-harmful/ Thanks to Josh and Bill
17. Building a theme Don’t start from scratch unless you must Build on top of something proven! “Blank” themes: Whiteboard, Sandbox, Starkers, etc Frameworks: Genesis!, Canvas, Builder, Hybrid, Headway, Thematic On top of popular themes: Twenty Ten Beware of Kubrick! http://wpcandy.com/presents/wordpress-theme-framework-comparison 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
18. Troubleshooting (do it) Errors? Warnings? Notices? White-screen-of-death? DON’T PANIC. Deep breaths. Debug! Most problems you can debug yourself. define('WP_DEBUG', true); Deactivate plugins Deactivate themes 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch
19. Getting Help Know where to go for help. All sources are not equal! Codex ( http://codex.wordpress.org) WordPress forums/support (http://wordpress.org/support/) Twitter e.g. #wordpress (hit or miss) IRC, #wordpress on irc.freenode.net http://codex.wordpress.org/IRC “3rd party” WP Tavern, StudioPress forums, Google, etc 12/4/2010 Oops! Common WordPress mistakes (and more) - Jared Atchison / @jaredatch