A short presentation about the new features in WordPress 3.1 and how they let you control every aspect of a site's content from the admin area including menus, widgets, post types and post formats.
5. Mmmmenus
Never hand code a menu again
Don’t worry about changing URLs
CSS Hooks a-plenty me hearties
Theme locations for different menus
Menu widget
12. Theme locations
“Primary Navigation” is the
theme location and “My
menu” is a menu selected
from the dropdown.
The code:
functions.php:
register_nav_menu( 'primary', 'My Menu' );
header.php
wp_nav_menu( array( 'theme_location' => 'primary' ) );
Further reading:
http://codex.wordpress.org/Function_Reference/wp_nav_menu
13. Extending menus
Custom Nav Walker Class
Show the description field
Show featured images from posts/pages
Access other page/post custom fields
14. Post types, or rather, content
types
Posts and pages are both post types
As are attachments
WordPress is built on its own API
The same API is available to theme & plugin
developers
15. What problem do
they solve?
Things that are neither posts nor pages
Forums – bbPress plugin
Properties
Events
Static blocks
Landing pages
Other applications
16. Register the hell out
of that post type
add_action('init', 'codex_custom_init');
function codex_custom_init() {
register_post_type('book', array(
'labels' => $labels,
'show_ui' => true,
'show_in_menu' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'supports' => array('title','editor','thumbnail')
) );
}
17. You can always cheat
Themergency custom post type generator
http://themergency.com/generators/wordpress-custom-post-types/
19. Modifying the
edit screen
Use the
metabox API
to add/remove
or reorder
metaboxes.
Example:
Blobs plugin
http://codex.wordpress.o
rg/Function_Reference/a
dd_meta_box
20. Metaboxes
add_meta_box( $id, $title, $callback, $post_type, $context, $priority,
$callback_args );
$callback is a the name of a function that
displays the content eg. Form fields
$context determines where the box appears eg.
‘side’ or ‘normal’
$priority allows you to control the order boxes
appear in eg. ‘high’ or ‘low’
21. Metaboxes
Provide user friendly alternatives to custom
fields
Server side validation for custom fields eg.
sanitize_title_with_dashes( $_POST[‘my_field’] );
Use the ‘save_post’ action
update_post_meta($post_id, $meta_key, $meta_value);
Accessing post meta
get_post_meta($post_id, $key, $single);
get_post_custom();
22. More cheating
Lots of tutorials out there
http://www.netmagazine.com/tutorials/user-
friendly-custom-fields-meta-boxes-wordpress
Or if you’re not into coding
http://wordpress.org/extend/plugins/more-fields/
25. Its got a widget
Typically in a sidebar
Can be anywhere in a theme – “Widget areas”
Many plugins provide widgets
Rapid prototyping of information architecture
26. A widget it has got
Widget
areas on
interconnecti
t.com make
up the home
page and
footer
section
Page widget (+ jQuery)
Text Widget
Posts widgets
Authors widget
Archive widget
Further reading:
http://codex.wordpress.org/Widgets_A
PI
27. Making sidebars
register_sidebar( $args );
Can be done programmatically
Widget area per category, per page etc...
Could even use a custom menu walker to
show widgets in a menu – mega menus!
Further Reading:
http://justintadlock.com/archives/2010/11/08/sidebars-in-wordpress
28. Post formats
Differentiate content within a post type
Think tumblr without the threat of tumbeasts
Portable between themes
Custom layouts for posts
29. Post formats
Supported formats: Aside, Gallery, Link, Image,
Quote, Status, Video, Audio, Chat
add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
Per post type:
add_post_type_support( $post_type, 'post-formats' );
In the loop:
has_post_format( $format );
33. In summary
Menus take the pain out of site navigation
Post types make WP suitable for many
applications
Widgets make it easy to refine information
architecture
Post formats are frickin cool
34. And it’s goodnight from him
Thanks for listening
Robert O’Rourke
http://sanchothefat.com
@sanchothefat
Editor's Notes
Hellos!
Welcome to the presentation
I will going over some of the recent advances in the WordPress core that make it much more powerful as a cms
Why would you want to content manage everything?
You’ve got better things to do...
While I won’t be going into a huge amount of detail here I hop eto rpvide you with an overview iof what can be done.
We’ll be covering Menus, Post types, Widgets and Post formats
Lists of links are the bread & nutter of the web. They’re everywhere. -
In the past whenusing wordpress as a cms it was an all/nothing approach to do it programmatically -
Hands up who’s hand coded a menu? -
Lists of links can be really simple -
They can be more complex like an archive -
Or super massive like on a news site
Changing URLs – when moving from local to dev & back again, it just works -
CSS Hooks – will see a short example -
Theme Locations – place created menus within a theme –
Menu widget to put links anywhere
The menu admin is tied into the theme being used so you’ll find it in the Appearance dropdown -
Create a menu by typing the name in the box and clicking create -
So far so good -
The menu admin is tied into the theme being used so you’ll find it in the Appearance dropdown
Create a menu by typing the name in the box and clicking create
So far so good
Adding links is easy –
Boxes provide a way of adding arbritrary links and also link within the site –
Check the boxes and add to menu
Drag & Drop
Don’t forget to save changes
Drag & Drop
Indent to make submenus
Don’t forget to save changes
Screen options!
Easy to miss hiding up there in the corner -
Use it to show more fields than normal in the link edit box -
Use it to show selection boxes on left – Links to post types and taxonomies -
Theme locations are where the magic happens -
They let you direct menus you’ve created to sections of the site -
The code is literally that simple, although there are plenty more options, filters & hooks available -
Recommend googling the top line and you’ll find good tutorials -
Useful to know exactly what is possible
Image below shows a menu with a custom walker. -
Featured images from posts are shown at a custom image size. –
Use the object_type property -
Categories have a bit of extra magic to enable images – wordpress.stackexchange.com -
Could even go so far as to show a widget areas for the menu items! Slightly mad but sometimes you need a mega menu
Post types should really be called content types -
Within wordpress posts and pages are the default post types –
You can use the functions wp uses itself to add more post types
Post types allow you to separate your content especially when it’s specific to what the theme or plugin needs to do. -
Forums via bbPress plugin forums, topic & replies are all post types -
Properties – a theme or plugin that provides a way to list properties on a website -
Static blocks –
Appthemes -
Labels is an array of labels – too much to show here -
Show ui – shows it in the admin menu –
Show in menu – Show post type on menus screen -
Definitely the quickest way to create the code you need -
Use output in your theme’s functions.php or in your plugin.
Basically the same as posts/pages admin -
You can edit the table columns and filter section at the top but it’s fairly complicated – wp.stackexchange
Blobs plugin – adds a simple way to create rich content boxes that can be called in the theme via shortcodes, widget or template tag -
User friendly ‘custom fields’ -
Example: 404 page message, no results found message, static ‘rich’ text in a sidebar
So called because of how the database works -
Posts table provides underlying structure -
Posts can be extended with post meta -
Abstraction layer on top of the custom fields box
Custom fields not the most user friendly thing to rely on for clients
Use metaboxes
Codex is a great resource
Google this stuff because there’s lots of good tuts out there -
Plugins are an alternative
Admin page has custom boxes for flickr gallery, user, set etc... And the id of said gallery, user or set
Theme integrated with gravity forms -
Metaboxes for tracking codes, extra content spaces, page layouts, gravity forms integration
Widgets are an incredibly useful tool in WordPress for building up structure and IA -
Lots of plugin have them like gravity forms, our weather widget, the blobs plugin, menus -
Things that are the same across multiple pages but that need to be editable at a moments notice – ideally by the client/site owner
Lots of types of widgets
Easy to build them just follow the example and you’re away.
Default widgets in default-widgets file of wp-includes
The sky is the limit
You can create sidebars in your init function based on existing pages/categories even menu items to make your sites hugely dynamic and flexible.
A special taxonomy with an interface that only allows you to set one option -
Previously used categories eg. ‘gallery’ but gets messy quickly. Also clients may accidentally place something in two cats that have custom layouts. -
Was typing in tumbeasts it tried to auto-correct to FU-beasts
A special taxonomy with an interface that only allows you to set one option -
Previously used categories eg. ‘gallery’ but gets messy quickly. Also clients may accidentally place something in two cats that have custom layouts.
Latest 2010 theme post formats
Latest version of twenty theme displays gallery posts like this in a list.
Auld by woothemes
Wumblr by themify
Shelf by thethemefoundry