4. Who Am I?
Conflicted: ½ Entrepreneur, ½ Web Developer
Founder &Prez of NewClarity in Atlanta – We:
Build Plugins for Distribution via WordPress.org
Extend WordPress for Vertical Market CMS
Active Teacher
350+ Answers on SE’s WordPress Answers
Former Meetup Organizer & Presenter
Former Developer Trainer
5. What do I know?
Tends to develop deep expertise in narrow areas.
2010-2012 – WordPress + PHP + MySQL + jQuery
2007-2009 – Drupal + PHP + MySQL
1995-2006 – ASP + VBScript + MS SQL Server
1993-1994 – Visual Basic + Access Database
1987-1993 – Clipper for DOS
1985-1986 – dBase II & dBase III
1983-1984 – Turbo Pascal
6.
7. My Primary Toolset
Mostly commercial because they are worth it.
PhpStorm ($99) + Zend Debugger (free)
Navicat for MySQL ($79)
VirtualHostX ($40)
Transmit for FTP ($34)/FileZilla (free)
HTTPScoop ($15)
Apache+PHP (on Mac OS X), MySQL (free)
8. What We’ll Cover Today
Everything will be in PHP
1. Define a Custom Post Type in PHP
2. Custom Form ("MetaBox") + Custom Fields
3. Theme Template for Custom Post Type
4. Custom Columns in Admin Post List
5. Custom Taxonomies for any Post Type
9. Today (cont’d)
6. Configure Edit Screens for Posts and Pages
7. Parent Post Field in a Post Editor Metabox
8. Querying Custom Post Types
9. Hierarchical URLs for Custom Post Types
10. Custom Post Type Filters in Admin Post List
Recognize and Bypass the Various Gotchas!
31. Update Custom Fields:
add_action( 'save_post', 'mikes_theme_save_post');
function mikes_theme_save_post( $post_id ) {
if ( 'comic' == $post_type ) {
update_post_meta($post_id,'_cartoonist',$_POST['cartoonist']);
update_post_meta($post_id,'_since',$_POST['since']);
update_post_meta($post_id,'_website',$_POST['website']);
}
}
Note the leading underscores on the
post meta 'key' names (2nd parameter)
50. Use the "Comic" Drop Down within the hook
'mikes_theme_episode_meta_box'
function mikes_theme_episode_meta_box( $post ) {
$select_html = mikes_theme_comic_dropdown( $post->post_parent );
$html =<<<HTML
<table>
<tr>
<th><label for="parent_id">Comic:</label></th>
<td>{$select_html}</td>
</tr>
</table>
HTML;
echo $html;
}
51. Use WP_Query() to create a "Comic" Drop
Down for "Episode" Parent Selection
function mikes_theme_comic_dropdown( $selected_id ) {
$query = new WP_Query( 'post_type=comic&posts_per_page=-1' );
$comics = array();
foreach( $query->posts as $comic ) {
$title = get_the_title( $comic->ID );
$selected = $comic->ID == intval( $selected_id ) ? ' selected' : '';
$comics[ $comic->ID ] = <<<HTML
<option value="{$comic->ID}"{$selected}>{$title}</option>
HTML;
}
$comics = implode( '', $comics );
$html =<<<HTML
<select name="parent_id">
<option value="0">None selected</option>
{$comics}
</select>
HTML;
return $html;
}
54. Enable /comics/{$comic}/{$episode}/
such as/comics/small-world/xmas-2012/
1. Call add_rewrite_rule()in 'init'hook.
2. Add 'query_var'arguments to 'comic' and
'episode' post types named 'comic_qv' and
'episode_qv', respectively.
3. Add 'post_type_link' hook.
4. Add 'request'hook.
68. Look for “Sunrise”
A Platform Extension for WordPress
Targeting needs of Professional Site Builders
To be GPL and freely distributed
Designed to be Modular
Goal: To Have Community of Module Contributors
Timeline:
Pre-Alpha now
Closed Beta – Q1 2012
Open Beta – Q2 2012
Release – Hmm…
69. Thank You
To Contact Me:
Twitter: @mikeschinkel
http://about.me/mikeschinkel