What you should be utilising in the Twenty Ten functions.php

7,652 views

Published on

The slides from my talk at WordCamp Melbourne.

Code for the demo theme available here: http://www.sennza.com.au/demo.zip

Published in: Education
3 Comments
5 Likes
Statistics
Notes
  • Hey Leon,

    Yeah you can do that. You can use the has_post_format() function: http://codex.wordpress.org/Function_Reference/has_post_format

    There is a good example here: http://wpmu.org/wordpress-3-1-post-formats-reference-by-lisa-sabin-wilson/
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Nice set of slides Bronson! post-formats looks very interesting as another option to style different kinds of posts - do you know if it's possible to filter posts by post-format?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • good post..............

    mobiles
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
7,652
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
22
Comments
3
Likes
5
Embeds 0
No embeds

No notes for slide

What you should be utilising in the Twenty Ten functions.php

  1. What you should be utilising in the Twenty Ten functions.php<br />A.k.a Pimp my theme!<br />By Bronson Quick<br />sennza | (07) 3040-1545 | bronson@sennza.com.au | http://www.sennza.com.au/ | Twitter: @sennza<br />
  2. Who Am I?<br /> I’m an infatuated WordPress geek<br />I contain these $args:<br /> I live in sunny (floody) Brisbane!<br /> I’m a partner @sennza http://www.sennza.com.au/<br /> Have been a geek for about 12 years...crap...I’m old!<br /> Have used many other CMS in the past...e.g. Joomla, Modx and loads of proprietary CMS<br /> Co – organizer of the WordPress Brisbane & WordPress Sydney Meetups http://www.wpbrisbane.com.au/ & http://www.wpsydney.com.au/<br /> Possible/probably/more then likely a co-organizer for WordCamp Gold Coast in late 2011 <br />Tweet us @sennza – Cool links and occasional blog posts<br />Tweet me @bronsonquick – Committing acts of random and bad taste humour...especially during all night coding sessions <br />Slide 2 of 20<br />rethink | redesign | results<br />
  3. What we’ll cover<br />A handful of functions in the functions.php file of the Twenty Ten theme<br />We’ll cover:<br /> What functions.php is and how you can use it in your themes<br /> add_editor_style();<br /> Post Formats (Yeah Baby!)<br /> Post Thumbnails - a.k.a How to save the ‘How do I size a photo’ calls from clients!<br /> register_nav_menus();<br /> add_custom_background();<br /> register_default_headers();<br />register_sidebar(); - Get yo’ widget on!<br />Questions & Answers<br />And den?? NO AND DEN!<br />Slide 3 of 20<br />rethink | redesign | results<br />
  4. Functions.php<br />A quick recap for those new to WordPress themes<br />What is functions.php?<br /> This file acts like a plugin<br /> You can add it to any theme<br />Loads automatically<br />Think about what you’re using and whether it should be in functions.php or a plugin<br />If it’s better off being a plugin then maybe it should live in the wp-content/mu-plugins folder?<br />http://codex.wordpress.org/Theme_Development#Functions_File<br />http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users<br />Slide 4 of 20<br />rethink | redesign | results<br />
  5. 2010 Functions.php<br />Have you had a read through it?<br />Why bother?<br /> Well documented<br /> Lots of tricks and code to refer back to for new projects<br />Starkers (Might take a little while for Elliot Jay Stocks to update for 3.1)<br />http://starkerstheme.com/<br />Slide 5 of 20<br />rethink | redesign | results<br />
  6. add_editor_style();<br />Add some styles to TinyMCE <br />What you need:<br />And create an editor-style.css with some CSS basic styles in it.<br />Slide 6 of 20<br />rethink | redesign | results<br />
  7. add_editor_style();<br />Add some styles to TinyMCE <br />Slide 7 of 20<br />rethink | redesign | results<br />
  8. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );<br />Gorgeousness in 3.1<br />New and exciting!Supports the following:<br />aside<br /> gallery<br /> link<br />image<br /> quote<br />status<br /> video<br />audio<br /> chat<br />http://starkerstheme.com/<br />Slide 8 of 20<br />rethink | redesign | results<br />
  9. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );<br />Gorgeousness in 3.1<br />Slide 9of 20<br />rethink | redesign | results<br />
  10. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );<br />What happens on the frontend<br />Style it up for your client!<br />Add icons, change the colour, add an icon...use your imagination!<br />Slide 10of 20<br />rethink | redesign | results<br />
  11. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );<br />Example<br />http://31.sennzademo.com/<br />Slide 11of 20<br />rethink | redesign | results<br />
  12. register_nav_menus();<br />Don’t just use one menu. Be creative!<br />What’s it do?<br /> Registers navigation menu positions!<br />Ditch your text widgets in the footer!register_nav_menus( array(<br />‘primary' => __( 'Primary Navigation', 'twentyten' ),<br />'secondary' => __( 'Secondary Navigation', 'twentyten' ),<br /> );<br />Then in footer.php add:<br /><?php wp_nav_menu( array( 'container_class' => 'menu-footer', 'theme_location' => 'secondary' ) ); ?><br />http://codex.wordpress.org/Function_Reference/register_nav_menus<br />Slide 12 of 20<br />rethink | redesign | results<br />
  13. add_custom_background();<br />Give your client some control<br />Slide 13 of 20<br />rethink | redesign | results<br />
  14. register_default_headers();<br />Variable logos, quarterly promos, think outside the box!<br />Slide 14 of 20<br />rethink | redesign | results<br />
  15. register_default_headers();<br />Variable logos, quarterly promos, think outside the box!<br />Slide 15 of 20<br />rethink | redesign | results<br />
  16. register_sidebar();<br />Widget the World Watcher!<br />What’s it do?<br /> Registers widget areas!<br />Add widgets into your theme to give you client more control. Think of places your client might want to put a promo image, advertisements and more!<br /> The code for functions.php:register_sidebar( array('name' => __( ‘Cool Widget Area', 'twentyten' ),'id' => ‘cool-widget-area‘,'description' => __( 'The cool widget area', 'twentyten' ),'before_widget' => '<li id="%1$s" class="widget-container %2$s">','after_widget' => '</li>','before_title' => '<h3 class="widget-title">','after_title' => '</h3>',) );<br />http://codex.wordpress.org/Function_Reference/register_sidebar<br />Slide 16 of 20<br />rethink | redesign | results<br />
  17. register_sidebar();<br />Widget the World Watcher!<br />The code for your theme:<?php if ( is_active_sidebar( ‘cool-widget-area' ) ) : ?><br /><div id=“cool" class="widget-area"><br /> <ul class="xoxo"><br /><?php dynamic_sidebar( ‘cool-widget-area' ); ?><br /></ul><br /> </div><!-- #cool .widget-area --><br /><?php endif; ?><br />http://codex.wordpress.org/Function_Reference/register_sidebar<br />Slide 17 of 20<br />rethink | redesign | results<br />
  18. register_sidebar();<br />Widget the World Watcher!<br />The results:<br />Slide 18 of 20<br />rethink | redesign | results<br />
  19. Thanks & Questions<br />Meetup groups<br />The Brisbane WordPress Meetup Group<br />http://www.wpbrisbane.com.au/<br />The Sydney WordPress Meetup Group<br />http://www.wpsydney.com.au/<br />Twitter<br />@sennza<br />@bronsonquick<br />Slide 19 of 20<br />rethink | redesign | results<br />
  20. bronson@sennza.com.au<br />http://www.sennza.com.au/<br />Twitter: @sennza<br />rethink | redesign | results<br />

×