SlideShare una empresa de Scribd logo
1 de 37
Descargar para leer sin conexión
DEMYSTIFYING
CUSTOM POST
TYPES &
TAXONOMIES
Tracey Kemp
@dogshindleg
➡ Registering Custom Post Types
  and Taxonomies

➡ A plugin that can help

➡ Displaying content from custom
  post types and taxonomies

➡ Resources
FINAL RESULT
A record label site with
artists and their releases.
PLANNING
What will be a custom post type and
what will be a taxonomy?

Custom Post Type       Taxonomy    Custom Post Type              Taxonomy               Taxonomy

Artist                 Location    Release                       Artist                 Year

The Drones             VIC         Here Come The Lies            The Drones             2002

The Kill Devil Hills   WA          Wait Long By The River        The Drones             2005

Midget                 NSW / QLD   Gala Mill                     The Drones             2006

Front End Loader       NSW         Havilah                       The Drones             2008

Dan Kelly              VIC         Heathen Songs                 The Kill Devil Hills   2004

                                   The Drought                   The Kill Devil Hills   2006

                                   Man, You Should Explode       The Kill Devil Hills   2010

                                   Vagus Wandering               Midget                 1994

                                   The Toggle Switch             Midget                 1997

                                   Total Abandonment Of Better   Midget                 1998
                                   Understanding
REGISTER
CUSTOM
POST
TYPES
REGISTER   function register_custom_post_types() {
                // register post types here
CUSTOM
           }
POST
           add_action(‘init’, ‘register_custom_post_types’);
TYPES
function register_custom_post_types() {
                register_post_type(
                      ‘artists’,
                             array(
                            ‘labels’ => array(
REGISTER                          ‘name’ => _x(‘Artists’, ‘post type general name’),
                                  ‘singular_name’ => __( ‘Artist’, ‘taxonomy singular name’ ),
ARTISTS                           ‘all_items’ => __( ‘All Artists’ ),
                                  ‘edit_item’ => __( ‘Edit Artist’ ),
                                  ‘add_new_item’ => __( ‘Add New Artist’ ),
                                  ‘new_item_name’ => __( ‘New Artist’ ),
                             ),
                      ‘public’ => true,
                      ‘show_ui’ => true,
                      ‘hierarchical’ => true,
                      ‘supports’ => array (‘title’,‘editor’, ‘thumbnail’)
                      )
                );
           }

           add_action(‘init’, ‘register_custom_post_types’);
function register_custom_post_types() {
                  register_post_type(
                          ‘artists’,
                                   array(
                                   ‘labels’ => array(
                                           ‘name’ => _x(‘Artists’, ‘post type general name’),
REGISTER                                   ‘singular_name’ => __( ‘Artist’, ‘taxonomy singular name’ ),
                                           ‘all_items’ => __( ‘All Artists’ ),
                                           ‘edit_item’ => __( ‘Edit Artist’ ),
ARTISTS                                    ‘add_new_item’ => __( ‘Add New Artist’ ),
                                           ‘new_item_name’ => __( ‘New Artist’ ),
                                   ),
                          ‘public’ => true,
                          ‘show_ui’ => true,
                          ‘hierarchical’ => true,
                          ‘supports’ => array (‘title’,‘editor’, ‘thumbnail’)
                          )
                  );




REGISTER
RELEASES


           }

           add_action(‘init’, ‘register_custom_post_types’);
function register_custom_post_types() {
                  register_post_type(
                          ‘artists’,
                                   array(
                                   ‘labels’ => array(
                                           ‘name’ => _x(‘Artists’, ‘post type general name’),
REGISTER                                   ‘singular_name’ => __( ‘Artist’, ‘taxonomy singular name’ ),
                                           ‘all_items’ => __( ‘All Artists’ ),
                                           ‘edit_item’ => __( ‘Edit Artist’ ),
ARTISTS                                    ‘add_new_item’ => __( ‘Add New Artist’ ),
                                           ‘new_item_name’ => __( ‘New Artist’ ),
                                   ),
                          ‘public’ => true,
                          ‘show_ui’ => true,
                          ‘hierarchical’ => true,
                          ‘supports’ => array (‘title’,‘editor’, ‘thumbnail’)
                          )
                  );
                  register_post_type(
                          ‘releases’,
                                   array(
                                   ‘labels’ => array(
                                           ‘name’ => _x(‘Releases’, ‘post type general name’),
REGISTER                                   ‘singular_name’ => __( ‘Release’, ‘taxonomy singular name’ ),
                                           ‘all_items’ => __( ‘All Releases’ ),

RELEASES                                   ‘edit_item’ => __( ‘Edit Release’ ),
                                           ‘add_new_item’ => __( ‘Add New Release’ ),
                                           ‘new_item_name’ => __( ‘New Release’ ),
                                   ),
                          ‘public’ => true,
                          ‘show_ui’ => true,
                          ‘hierarchical’ => true,
                          ‘supports’ => array (‘title’, ‘editor’, ‘thumbnail’)
                          )
                  );
           }

           add_action(‘init’, ‘register_custom_post_types’);
function register_custom_post_types() {
                  register_post_type(
                          ‘artists’,
                                   array(
                                   ‘labels’ => array(
                                           ‘name’ => _x(‘Artists’, ‘post type general name’),
REGISTER                                   ‘singular_name’ => __( ‘Artist’, ‘taxonomy singular name’ ),
                                           ‘all_items’ => __( ‘All Artists’ ),
                                           ‘edit_item’ => __( ‘Edit Artist’ ),
ARTISTS                                    ‘add_new_item’ => __( ‘Add New Artist’ ),
                                           ‘new_item_name’ => __( ‘New Artist’ ),
                                   ),
                          ‘public’ => true,
                          ‘show_ui’ => true,
                          ‘hierarchical’ => true,
                          ‘supports’ => array (‘title’,‘editor’, ‘thumbnail’)
                          )
                  );
                  register_post_type(
                          ‘releases’,
                                   array(
                                   ‘labels’ => array(
                                           ‘name’ => _x(‘Releases’, ‘post type general name’),
REGISTER                                   ‘singular_name’ => __( ‘Release’, ‘taxonomy singular name’ ),
                                           ‘all_items’ => __( ‘All Releases’ ),

RELEASES                                   ‘edit_item’ => __( ‘Edit Release’ ),
                                           ‘add_new_item’ => __( ‘Add New Release’ ),
                                           ‘new_item_name’ => __( ‘New Release’ ),
                                   ),
                          ‘public’ => true,
                          ‘show_ui’ => true,
                          ‘hierarchical’ => true,
                          ‘supports’ => array (‘title’, ‘editor’, ‘thumbnail’)
                          )
                  );
           }

           add_action(‘init’, ‘register_custom_post_types’);
REGISTER
TAXONOMIES
REGISTER   function register_taxonomies() {

TAXO            // register post types here

NOMIES     }

           add_action(‘init’, ‘register_taxonomies’, 0);
function register_taxonomies() {
                $labels = array(
                   ‘name’ => _x( ‘Location’, ‘taxonomy general name’ ),
                   ‘singular_name’ => _x( ‘Location’, ‘taxonomy singular name’ ),
REGISTER           ‘all_items’ => __( ‘All Locations’ ),
                   ‘edit_item’ => __( ‘Edit Location’ ),
LOCATION           ‘add_new_item’ => __( ‘Add New Location’ ),
                   ‘menu_name’ => __( ‘Locations’ ),
                );
                register_taxonomy(
                   ‘locations’,
                   array(‘artists’), // post-type(s)
                   array(
                       ‘hierarchical’ => true,
                       ‘labels’ => $labels,
                       ‘show_ui’ => true, )
                );
           }

           add_action(‘init’, ‘register_taxonomies’, 0);
function register_taxonomies() {
                   $labels = array(
                        ‘name’ => _x( ‘Location’, ‘taxonomy general name’ ),
                        ‘singular_name’ => _x( ‘Location’, ‘taxonomy singular name’ ),
                        ‘all_items’ => __( ‘All Locations’ ),
                        ‘edit_item’ => __( ‘Edit Location’ ),

REGISTER                ‘add_new_item’ => __( ‘Add New Location’ ),
                        ‘menu_name’ => __( ‘Locations’ ),
                   );
LOCATION           register_taxonomy(
                        ‘locations’,
                        array(‘artists’), // post-type(s)
                        array(
                              ‘hierarchical’ => true,
                              ‘labels’ => $labels,
                              ‘show_ui’ => true, )
                   );




REGISTER
RELEASE
YEAR
           }

           add_action(‘init’, ‘register_taxonomies’, 0);
function register_taxonomies() {
                   $labels = array(
                        ‘name’ => _x( ‘Location’, ‘taxonomy general name’ ),
                        ‘singular_name’ => _x( ‘Location’, ‘taxonomy singular name’ ),
                        ‘all_items’ => __( ‘All Locations’ ),
                        ‘edit_item’ => __( ‘Edit Location’ ),

REGISTER                ‘add_new_item’ => __( ‘Add New Location’ ),
                        ‘menu_name’ => __( ‘Locations’ ),
                   );
LOCATION           register_taxonomy(
                        ‘locations’,
                        array(‘artists’), // post-type(s)
                        array(
                              ‘hierarchical’ => true,
                              ‘labels’ => $labels,
                              ‘show_ui’ => true, )
                   );
                   $labels = array(
                        ‘name’ => _x( ‘Release Year’, ‘taxonomy general name’ ),
                        ‘singular_name’ => _x( ‘Release Year’, ‘taxonomy singular name’ ),
                        ‘all_items’ => __( ‘All Release Years’ ),
                        ‘edit_item’ => __( ‘Edit Release Year’ ),
                        ‘add_new_item’ => __( ‘Add New Release Year’ ),
                        ‘menu_name’ => __( ‘Release Years’ ),

REGISTER           );
                   register_taxonomy(
                        ‘release-year’,
RELEASE                 array(‘releases’), // post-type(s)
                        array(

YEAR                          ‘hierarchical’ => true,
                              ‘labels’ => $labels,
                              ‘show_ui’ => true, )
                   );
           }

           add_action(‘init’, ‘register_taxonomies’, 0);
function register_taxonomies() {
                   $labels = array(
                        ‘name’ => _x( ‘Location’, ‘taxonomy general name’ ),
                        ‘singular_name’ => _x( ‘Location’, ‘taxonomy singular name’ ),
                        ‘all_items’ => __( ‘All Locations’ ),
                        ‘edit_item’ => __( ‘Edit Location’ ),

REGISTER                ‘add_new_item’ => __( ‘Add New Location’ ),
                        ‘menu_name’ => __( ‘Locations’ ),
                   );
LOCATION           register_taxonomy(
                        ‘locations’,
                        array(‘artists’), // post-type(s)
                        array(
                              ‘hierarchical’ => true,
                              ‘labels’ => $labels,
                              ‘show_ui’ => true, )
                   );
                   $labels = array(
                        ‘name’ => _x( ‘Release Year’, ‘taxonomy general name’ ),
                        ‘singular_name’ => _x( ‘Release Year’, ‘taxonomy singular name’ ),
                        ‘all_items’ => __( ‘All Release Years’ ),
                        ‘edit_item’ => __( ‘Edit Release Year’ ),
                        ‘add_new_item’ => __( ‘Add New Release Year’ ),
                        ‘menu_name’ => __( ‘Release Years’ ),

REGISTER           );
                   register_taxonomy(
                        ‘release-year’,
RELEASE                 array(‘releases’), // post-type(s)
                        array(

YEAR                          ‘hierarchical’ => true,
                              ‘labels’ => $labels,
                              ‘show_ui’ => true, )
                   );
           }

           add_action(‘init’, ‘register_taxonomies’, 0);
USING A
CUSTOM POST
TYPE AS A
TAXONOMY
DISPLAY
ARTISTS
DISPLAY
ARTISTS
<?php //artists posts
$artist_args=array(
     'post_type' => 'artists',
     'posts_per_page' => -1,
);
$artist_query = null;
$artist_query = new WP_Query($artist_args);
if( $artist_query->have_posts() ) {
  while ($artist_query->have_posts()) : $artist_query->the_post(); ?>

   <article>
      <?php the_post_thumbnail(); ?>
      <h2><?php the_title(); ?></h2>
      <?php the_excerpt(); ?>
   </article>

<?php endwhile; } wp_reset_query(); ?>
DISPLAY ARTISTS
WITH LOCATIONS
<?php //artists posts
$artist_args=array(
     'post_type' => 'artists',
     'posts_per_page' => -1,
);
$artist_query = null;
$artist_query = new WP_Query($artist_args);
if( $artist_query->have_posts() ) {
  while ($artist_query->have_posts()) : $artist_query->the_post(); ?>

   <article>
      <?php the_post_thumbnail(); ?>
      <h2><?php the_title(); ?></h2>
      <?php echo get_the_term_list( $post->ID, ‘locations’,
      ‘From: ’, ‘ / ‘, ‘’ ); ?>
      <?php the_excerpt(); ?>
   </article>

<?php endwhile; } wp_reset_query(); ?>
DISPLAY ARTISTS
WITH LOCATIONS
<?php //artists posts
$artist_args=array(
     'post_type' => 'artists',
     'posts_per_page' => -1,
);
     <?php echo get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?>
$artist_query = null;
$artist_query = new WP_Query($artist_args);
     <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?>
if( $artist_query->have_posts() ) {
  while ($artist_query->have_posts()) : $artist_query->the_post(); ?>

   <article>
      <?php the_post_thumbnail(); ?>
      <h2><?php the_title(); ?></h2>
      <?php echo get_the_term_list( $post->ID, ‘locations’,
      ‘From: ’, ‘ / ‘, ‘’ ); ?>
      <?php the_excerpt(); ?>
   </article>

<?php endwhile; } wp_reset_query(); ?>
DISPLAY
RELEASES
<?php //releases posts
$release_args=array(
     'post_type' => 'releases',
     'posts_per_page' => -1,
);
$release_query = null;
$release_query = new WP_Query($release_args);
if( $release_query->have_posts() ) {
  while ($release_query->have_posts()) : $release_query->the_post(); ?>

   <article>
      <?php the_post_thumbnail(); ?>
      <?php the_title(); ?>
      <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?>
   </article>

<?php endwhile; } wp_reset_query(); ?>
DISPLAY
RELEASES
<?php //releases posts
$release_args=array(
     'post_type' => 'releases',
     'posts_per_page' => -1,
);
$release_query = null;
$release_query = new WP_Query($release_args);
if( $release_query->have_posts() ) {
  while ($release_query->have_posts()) : $release_query->the_post(); ?>

   <article>
      <?php the_post_thumbnail(); ?>
      <?php the_title(); ?>
      <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?>
   </article>

<?php endwhile; } wp_reset_query(); ?>
HOW DO WE SHOW ARTISTS WITH RELEASES?
<?php //artists posts
          $artist_args=array(
               'post_type' => 'artists',
DISPLAY        'posts_per_page' => -1,
ARTISTS   );
          $artist_query = null;
          $artist_query = new WP_Query($artist_args);
          if( $artist_query->have_posts() ) {
            while ($artist_query->have_posts()) : $artist_query->the_post(); ?>

             <article>
               <?php the_post_thumbnail(); ?>
               <h2><?php the_title(); ?></h2>
               <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?>
               <?php the_excerpt(); ?>

                //insert releases here

             </article>

          <?php endwhile; } wp_reset_query(); ?>
while ($artist_query->have_posts()) : $artist_query->the_post(); ?>


DISPLAY     <article>
              <?php the_post_thumbnail(); ?>
ARTISTS       <h2><?php the_title(); ?></h2>
              <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?>
              <?php the_excerpt(); ?>

                    <?php //releases posts
                    $release_args=array(
                         'post_type' => 'releases',
                         'posts_per_page' => -1,
DISPLAY             );
                    $release_query = null;
RELEASES            $release_query = new WP_Query($release_args);
                    if( $release_query->have_posts() ) {
                      while ($release_query->have_posts()) : $release_query->the_post(); ?>

                         <article>
                            <?php the_post_thumbnail(); ?>
                            <?php the_title(); ?>
                            <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?
                         </article>

                    <?php endwhile; } wp_reset_query(); ?>
            </article>
while ($artist_query->have_posts()) : $artist_query->the_post(); ?>


DISPLAY             <article>
                      <?php the_post_thumbnail(); ?>
ARTISTS               <h2><?php the_title(); ?></h2>
                      <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?>
                      <?php the_excerpt(); ?>

GET ARTIST TITLE
                            <?php //releases posts
                            $release_args=array(
                                 'post_type' => 'releases',
                                 'posts_per_page' => -1,
                            );
DISPLAY                     $release_query = null;
                            $release_query = new WP_Query($release_args);
RELEASES                    if( $release_query->have_posts() ) {
                              while ($release_query->have_posts()) : $release_query->the_post(); ?>

                               <article>
                                  <?php the_post_thumbnail(); ?>
                                  <?php the_title(); ?>
                                  <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?
                               </article>
while ($artist_query->have_posts()) : $artist_query->the_post(); ?>


DISPLAY             <article>
                      <?php the_post_thumbnail(); ?>
ARTISTS               <h2><?php the_title(); ?></h2>
                      <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?>
                      <?php the_excerpt(); ?>

GET ARTIST TITLE            <?php $tax_artist = get_the_title(); ?>

                            <?php //releases posts
                            $release_args=array(
                                 'post_type' => 'releases',
                                 'posts_per_page' => -1,
                            );
DISPLAY                     $release_query = null;
                            $release_query = new WP_Query($release_args);
RELEASES                    if( $release_query->have_posts() ) {
                              while ($release_query->have_posts()) : $release_query->the_post(); ?>

                               <article>
                                  <?php the_post_thumbnail(); ?>
                                  <?php the_title(); ?>
                                  <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?
                               </article>
while ($artist_query->have_posts()) : $artist_query->the_post(); ?>


DISPLAY             <article>
                      <?php the_post_thumbnail(); ?>
ARTISTS               <h2><?php the_title(); ?></h2>
                      <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?>
                      <?php the_excerpt(); ?>

GET ARTIST TITLE            <?php $tax_artist = get_the_title(); ?>

                            <?php //releases posts
                            $release_args=array(
                                 'post_type' => 'releases',
$taxonomy => $term               'artists' => $tax_artist,
                                 'posts_per_page' => -1,
                            );
                            $release_query = null;
                            $release_query = new WP_Query($release_args);
                            if( $release_query->have_posts() ) {
DISPLAY                       while ($release_query->have_posts()) : $release_query->the_post(); ?>
RELEASES                       <article>
                                  <?php the_post_thumbnail(); ?>
                                  <?php the_title(); ?>
                                  <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?
                               </article>
<?php //artists posts
                   $artist_args=array(
                         'post_type' => 'artists',
START              );
                         'posts_per_page' => -1,


ARTISTS            $artist_query = null;
                   $artist_query = new WP_Query($artist_args);
QUERY              if( $artist_query->have_posts() ) {
                     while ($artist_query->have_posts()) : $artist_query->the_post(); ?>

                       <article>
                            <?php the_post_thumbnail(); ?>
                            <h2><?php the_title(); ?></h2>
                            <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?>
                            <?php the_excerpt(); ?>

GET ARTIST TITLE                    <?php $tax_artist = get_the_title(); ?>
                                    <?php //releases posts
                                    $release_args=array(
START RELEASES QUERY                      'post_type' => 'releases',
$taxonomy => $term                        'artists' => $tax_artist,
                                          'posts_per_page' => -1,
                                    );
                                    $release_query = null;
                                    $release_query = new WP_Query($release_args);
                                    if( $release_query->have_posts() ) {
                                      while ($release_query->have_posts()) : $release_query->the_post(); ?>

                                        <article>
                                             <?php the_post_thumbnail(); ?>
                                             <?php the_title(); ?>
                                             <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?>
                                        </article>
CLOSE RELEASES                      <?php endwhile; } wp_reset_query(); ?>

CLOSE                  </article>

ARTISTS            <?php endwhile; } wp_reset_query(); ?>
RESOURCES
WordPress Codex & Forums
http://codex.wordpress.org/
http://wordpress.org/support/

Register Custom Post Types
http://codex.wordpress.org/Function_Reference/register_post_type

Register Taxonomies
http://codex.wordpress.org/Function_Reference/register_taxonomy

Query Posts
http://codex.wordpress.org/Function_Reference/query_posts

The Loop
http://codex.wordpress.org/The_Loop
RESOURCES
Plugins
CPT-onomies: Using Custom Post Types as Taxonomies
http://wordpress.org/extend/plugins/cpt-onomies/
DEMYSTIFYING
CUSTOM POST
TYPES &
TAXONOMIES
Tracey Kemp
@dogshindleg


Full code samples and explanations
dogshindleg.com

Más contenido relacionado

Más de WordCamp Sydney

TurboPress: The High Performance Guide to WordPress - Jeff Waugh - WordCamp S...
TurboPress: The High Performance Guide to WordPress - Jeff Waugh - WordCamp S...TurboPress: The High Performance Guide to WordPress - Jeff Waugh - WordCamp S...
TurboPress: The High Performance Guide to WordPress - Jeff Waugh - WordCamp S...WordCamp Sydney
 
Responsive WordPress - Jordan Gillman - WordCamp Sydney 2012
Responsive WordPress - Jordan Gillman - WordCamp Sydney 2012Responsive WordPress - Jordan Gillman - WordCamp Sydney 2012
Responsive WordPress - Jordan Gillman - WordCamp Sydney 2012WordCamp Sydney
 
The Power of Your Story Through WordPress and Social Media - Kimanzi Constabl...
The Power of Your Story Through WordPress and Social Media - Kimanzi Constabl...The Power of Your Story Through WordPress and Social Media - Kimanzi Constabl...
The Power of Your Story Through WordPress and Social Media - Kimanzi Constabl...WordCamp Sydney
 
Siloing your Site for SEO Success - Stephen Cronin - WordCamp Sydney 2012
Siloing your Site for SEO Success - Stephen Cronin - WordCamp Sydney 2012Siloing your Site for SEO Success - Stephen Cronin - WordCamp Sydney 2012
Siloing your Site for SEO Success - Stephen Cronin - WordCamp Sydney 2012WordCamp Sydney
 
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...WordCamp Sydney
 
The Plugin Spectactular - Tony Cosentino - WordCamp Sydney 2012
The Plugin Spectactular - Tony Cosentino - WordCamp Sydney 2012The Plugin Spectactular - Tony Cosentino - WordCamp Sydney 2012
The Plugin Spectactular - Tony Cosentino - WordCamp Sydney 2012WordCamp Sydney
 
Optimising SEO for WordPress - Lisa Davis - WordCamp Sydney 2012
Optimising SEO for WordPress - Lisa Davis - WordCamp Sydney 2012Optimising SEO for WordPress - Lisa Davis - WordCamp Sydney 2012
Optimising SEO for WordPress - Lisa Davis - WordCamp Sydney 2012WordCamp Sydney
 
Word to the Future - Brent Shepherd - WordCamp Sydney 2012
Word to the Future - Brent Shepherd - WordCamp Sydney 2012Word to the Future - Brent Shepherd - WordCamp Sydney 2012
Word to the Future - Brent Shepherd - WordCamp Sydney 2012WordCamp Sydney
 
Securing your WordPress Website - Vlad Lasky - WordCamp Sydney 2012
Securing your WordPress Website - Vlad Lasky - WordCamp Sydney 2012Securing your WordPress Website - Vlad Lasky - WordCamp Sydney 2012
Securing your WordPress Website - Vlad Lasky - WordCamp Sydney 2012WordCamp Sydney
 
There's More than 1 Way to Skin a WordPress Theme - Lachlan MacPherson - Word...
There's More than 1 Way to Skin a WordPress Theme - Lachlan MacPherson - Word...There's More than 1 Way to Skin a WordPress Theme - Lachlan MacPherson - Word...
There's More than 1 Way to Skin a WordPress Theme - Lachlan MacPherson - Word...WordCamp Sydney
 
WordPress for Noobs - Wil Brown - WordCamp Sydney 2012
WordPress for Noobs - Wil Brown - WordCamp Sydney 2012WordPress for Noobs - Wil Brown - WordCamp Sydney 2012
WordPress for Noobs - Wil Brown - WordCamp Sydney 2012WordCamp Sydney
 
Getting to Grips with Firebug - Anthony Hortin - WordCamp Sydney
Getting to Grips with Firebug - Anthony Hortin - WordCamp SydneyGetting to Grips with Firebug - Anthony Hortin - WordCamp Sydney
Getting to Grips with Firebug - Anthony Hortin - WordCamp SydneyWordCamp Sydney
 

Más de WordCamp Sydney (12)

TurboPress: The High Performance Guide to WordPress - Jeff Waugh - WordCamp S...
TurboPress: The High Performance Guide to WordPress - Jeff Waugh - WordCamp S...TurboPress: The High Performance Guide to WordPress - Jeff Waugh - WordCamp S...
TurboPress: The High Performance Guide to WordPress - Jeff Waugh - WordCamp S...
 
Responsive WordPress - Jordan Gillman - WordCamp Sydney 2012
Responsive WordPress - Jordan Gillman - WordCamp Sydney 2012Responsive WordPress - Jordan Gillman - WordCamp Sydney 2012
Responsive WordPress - Jordan Gillman - WordCamp Sydney 2012
 
The Power of Your Story Through WordPress and Social Media - Kimanzi Constabl...
The Power of Your Story Through WordPress and Social Media - Kimanzi Constabl...The Power of Your Story Through WordPress and Social Media - Kimanzi Constabl...
The Power of Your Story Through WordPress and Social Media - Kimanzi Constabl...
 
Siloing your Site for SEO Success - Stephen Cronin - WordCamp Sydney 2012
Siloing your Site for SEO Success - Stephen Cronin - WordCamp Sydney 2012Siloing your Site for SEO Success - Stephen Cronin - WordCamp Sydney 2012
Siloing your Site for SEO Success - Stephen Cronin - WordCamp Sydney 2012
 
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
 
The Plugin Spectactular - Tony Cosentino - WordCamp Sydney 2012
The Plugin Spectactular - Tony Cosentino - WordCamp Sydney 2012The Plugin Spectactular - Tony Cosentino - WordCamp Sydney 2012
The Plugin Spectactular - Tony Cosentino - WordCamp Sydney 2012
 
Optimising SEO for WordPress - Lisa Davis - WordCamp Sydney 2012
Optimising SEO for WordPress - Lisa Davis - WordCamp Sydney 2012Optimising SEO for WordPress - Lisa Davis - WordCamp Sydney 2012
Optimising SEO for WordPress - Lisa Davis - WordCamp Sydney 2012
 
Word to the Future - Brent Shepherd - WordCamp Sydney 2012
Word to the Future - Brent Shepherd - WordCamp Sydney 2012Word to the Future - Brent Shepherd - WordCamp Sydney 2012
Word to the Future - Brent Shepherd - WordCamp Sydney 2012
 
Securing your WordPress Website - Vlad Lasky - WordCamp Sydney 2012
Securing your WordPress Website - Vlad Lasky - WordCamp Sydney 2012Securing your WordPress Website - Vlad Lasky - WordCamp Sydney 2012
Securing your WordPress Website - Vlad Lasky - WordCamp Sydney 2012
 
There's More than 1 Way to Skin a WordPress Theme - Lachlan MacPherson - Word...
There's More than 1 Way to Skin a WordPress Theme - Lachlan MacPherson - Word...There's More than 1 Way to Skin a WordPress Theme - Lachlan MacPherson - Word...
There's More than 1 Way to Skin a WordPress Theme - Lachlan MacPherson - Word...
 
WordPress for Noobs - Wil Brown - WordCamp Sydney 2012
WordPress for Noobs - Wil Brown - WordCamp Sydney 2012WordPress for Noobs - Wil Brown - WordCamp Sydney 2012
WordPress for Noobs - Wil Brown - WordCamp Sydney 2012
 
Getting to Grips with Firebug - Anthony Hortin - WordCamp Sydney
Getting to Grips with Firebug - Anthony Hortin - WordCamp SydneyGetting to Grips with Firebug - Anthony Hortin - WordCamp Sydney
Getting to Grips with Firebug - Anthony Hortin - WordCamp Sydney
 

Último

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

Demystifying Custom Post Types and Taxonomies - Tracey Kemp - WordCamp Sydney 2012

  • 2. ➡ Registering Custom Post Types and Taxonomies ➡ A plugin that can help ➡ Displaying content from custom post types and taxonomies ➡ Resources
  • 3. FINAL RESULT A record label site with artists and their releases.
  • 4. PLANNING What will be a custom post type and what will be a taxonomy? Custom Post Type Taxonomy Custom Post Type Taxonomy Taxonomy Artist Location Release Artist Year The Drones VIC Here Come The Lies The Drones 2002 The Kill Devil Hills WA Wait Long By The River The Drones 2005 Midget NSW / QLD Gala Mill The Drones 2006 Front End Loader NSW Havilah The Drones 2008 Dan Kelly VIC Heathen Songs The Kill Devil Hills 2004 The Drought The Kill Devil Hills 2006 Man, You Should Explode The Kill Devil Hills 2010 Vagus Wandering Midget 1994 The Toggle Switch Midget 1997 Total Abandonment Of Better Midget 1998 Understanding
  • 6. REGISTER function register_custom_post_types() { // register post types here CUSTOM } POST add_action(‘init’, ‘register_custom_post_types’); TYPES
  • 7. function register_custom_post_types() { register_post_type( ‘artists’, array( ‘labels’ => array( REGISTER ‘name’ => _x(‘Artists’, ‘post type general name’), ‘singular_name’ => __( ‘Artist’, ‘taxonomy singular name’ ), ARTISTS ‘all_items’ => __( ‘All Artists’ ), ‘edit_item’ => __( ‘Edit Artist’ ), ‘add_new_item’ => __( ‘Add New Artist’ ), ‘new_item_name’ => __( ‘New Artist’ ), ), ‘public’ => true, ‘show_ui’ => true, ‘hierarchical’ => true, ‘supports’ => array (‘title’,‘editor’, ‘thumbnail’) ) ); } add_action(‘init’, ‘register_custom_post_types’);
  • 8. function register_custom_post_types() { register_post_type( ‘artists’, array( ‘labels’ => array( ‘name’ => _x(‘Artists’, ‘post type general name’), REGISTER ‘singular_name’ => __( ‘Artist’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Artists’ ), ‘edit_item’ => __( ‘Edit Artist’ ), ARTISTS ‘add_new_item’ => __( ‘Add New Artist’ ), ‘new_item_name’ => __( ‘New Artist’ ), ), ‘public’ => true, ‘show_ui’ => true, ‘hierarchical’ => true, ‘supports’ => array (‘title’,‘editor’, ‘thumbnail’) ) ); REGISTER RELEASES } add_action(‘init’, ‘register_custom_post_types’);
  • 9. function register_custom_post_types() { register_post_type( ‘artists’, array( ‘labels’ => array( ‘name’ => _x(‘Artists’, ‘post type general name’), REGISTER ‘singular_name’ => __( ‘Artist’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Artists’ ), ‘edit_item’ => __( ‘Edit Artist’ ), ARTISTS ‘add_new_item’ => __( ‘Add New Artist’ ), ‘new_item_name’ => __( ‘New Artist’ ), ), ‘public’ => true, ‘show_ui’ => true, ‘hierarchical’ => true, ‘supports’ => array (‘title’,‘editor’, ‘thumbnail’) ) ); register_post_type( ‘releases’, array( ‘labels’ => array( ‘name’ => _x(‘Releases’, ‘post type general name’), REGISTER ‘singular_name’ => __( ‘Release’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Releases’ ), RELEASES ‘edit_item’ => __( ‘Edit Release’ ), ‘add_new_item’ => __( ‘Add New Release’ ), ‘new_item_name’ => __( ‘New Release’ ), ), ‘public’ => true, ‘show_ui’ => true, ‘hierarchical’ => true, ‘supports’ => array (‘title’, ‘editor’, ‘thumbnail’) ) ); } add_action(‘init’, ‘register_custom_post_types’);
  • 10. function register_custom_post_types() { register_post_type( ‘artists’, array( ‘labels’ => array( ‘name’ => _x(‘Artists’, ‘post type general name’), REGISTER ‘singular_name’ => __( ‘Artist’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Artists’ ), ‘edit_item’ => __( ‘Edit Artist’ ), ARTISTS ‘add_new_item’ => __( ‘Add New Artist’ ), ‘new_item_name’ => __( ‘New Artist’ ), ), ‘public’ => true, ‘show_ui’ => true, ‘hierarchical’ => true, ‘supports’ => array (‘title’,‘editor’, ‘thumbnail’) ) ); register_post_type( ‘releases’, array( ‘labels’ => array( ‘name’ => _x(‘Releases’, ‘post type general name’), REGISTER ‘singular_name’ => __( ‘Release’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Releases’ ), RELEASES ‘edit_item’ => __( ‘Edit Release’ ), ‘add_new_item’ => __( ‘Add New Release’ ), ‘new_item_name’ => __( ‘New Release’ ), ), ‘public’ => true, ‘show_ui’ => true, ‘hierarchical’ => true, ‘supports’ => array (‘title’, ‘editor’, ‘thumbnail’) ) ); } add_action(‘init’, ‘register_custom_post_types’);
  • 12. REGISTER function register_taxonomies() { TAXO // register post types here NOMIES } add_action(‘init’, ‘register_taxonomies’, 0);
  • 13. function register_taxonomies() { $labels = array( ‘name’ => _x( ‘Location’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Location’, ‘taxonomy singular name’ ), REGISTER ‘all_items’ => __( ‘All Locations’ ), ‘edit_item’ => __( ‘Edit Location’ ), LOCATION ‘add_new_item’ => __( ‘Add New Location’ ), ‘menu_name’ => __( ‘Locations’ ), ); register_taxonomy( ‘locations’, array(‘artists’), // post-type(s) array( ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => true, ) ); } add_action(‘init’, ‘register_taxonomies’, 0);
  • 14. function register_taxonomies() { $labels = array( ‘name’ => _x( ‘Location’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Location’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Locations’ ), ‘edit_item’ => __( ‘Edit Location’ ), REGISTER ‘add_new_item’ => __( ‘Add New Location’ ), ‘menu_name’ => __( ‘Locations’ ), ); LOCATION register_taxonomy( ‘locations’, array(‘artists’), // post-type(s) array( ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => true, ) ); REGISTER RELEASE YEAR } add_action(‘init’, ‘register_taxonomies’, 0);
  • 15. function register_taxonomies() { $labels = array( ‘name’ => _x( ‘Location’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Location’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Locations’ ), ‘edit_item’ => __( ‘Edit Location’ ), REGISTER ‘add_new_item’ => __( ‘Add New Location’ ), ‘menu_name’ => __( ‘Locations’ ), ); LOCATION register_taxonomy( ‘locations’, array(‘artists’), // post-type(s) array( ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => true, ) ); $labels = array( ‘name’ => _x( ‘Release Year’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Release Year’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Release Years’ ), ‘edit_item’ => __( ‘Edit Release Year’ ), ‘add_new_item’ => __( ‘Add New Release Year’ ), ‘menu_name’ => __( ‘Release Years’ ), REGISTER ); register_taxonomy( ‘release-year’, RELEASE array(‘releases’), // post-type(s) array( YEAR ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => true, ) ); } add_action(‘init’, ‘register_taxonomies’, 0);
  • 16. function register_taxonomies() { $labels = array( ‘name’ => _x( ‘Location’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Location’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Locations’ ), ‘edit_item’ => __( ‘Edit Location’ ), REGISTER ‘add_new_item’ => __( ‘Add New Location’ ), ‘menu_name’ => __( ‘Locations’ ), ); LOCATION register_taxonomy( ‘locations’, array(‘artists’), // post-type(s) array( ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => true, ) ); $labels = array( ‘name’ => _x( ‘Release Year’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Release Year’, ‘taxonomy singular name’ ), ‘all_items’ => __( ‘All Release Years’ ), ‘edit_item’ => __( ‘Edit Release Year’ ), ‘add_new_item’ => __( ‘Add New Release Year’ ), ‘menu_name’ => __( ‘Release Years’ ), REGISTER ); register_taxonomy( ‘release-year’, RELEASE array(‘releases’), // post-type(s) array( YEAR ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => true, ) ); } add_action(‘init’, ‘register_taxonomies’, 0);
  • 17. USING A CUSTOM POST TYPE AS A TAXONOMY
  • 18.
  • 19.
  • 20.
  • 22. DISPLAY ARTISTS <?php //artists posts $artist_args=array( 'post_type' => 'artists', 'posts_per_page' => -1, ); $artist_query = null; $artist_query = new WP_Query($artist_args); if( $artist_query->have_posts() ) { while ($artist_query->have_posts()) : $artist_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <h2><?php the_title(); ?></h2> <?php the_excerpt(); ?> </article> <?php endwhile; } wp_reset_query(); ?>
  • 23. DISPLAY ARTISTS WITH LOCATIONS <?php //artists posts $artist_args=array( 'post_type' => 'artists', 'posts_per_page' => -1, ); $artist_query = null; $artist_query = new WP_Query($artist_args); if( $artist_query->have_posts() ) { while ($artist_query->have_posts()) : $artist_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <h2><?php the_title(); ?></h2> <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> <?php the_excerpt(); ?> </article> <?php endwhile; } wp_reset_query(); ?>
  • 24. DISPLAY ARTISTS WITH LOCATIONS <?php //artists posts $artist_args=array( 'post_type' => 'artists', 'posts_per_page' => -1, ); <?php echo get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?> $artist_query = null; $artist_query = new WP_Query($artist_args); <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> if( $artist_query->have_posts() ) { while ($artist_query->have_posts()) : $artist_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <h2><?php the_title(); ?></h2> <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> <?php the_excerpt(); ?> </article> <?php endwhile; } wp_reset_query(); ?>
  • 25. DISPLAY RELEASES <?php //releases posts $release_args=array( 'post_type' => 'releases', 'posts_per_page' => -1, ); $release_query = null; $release_query = new WP_Query($release_args); if( $release_query->have_posts() ) { while ($release_query->have_posts()) : $release_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <?php the_title(); ?> <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?> </article> <?php endwhile; } wp_reset_query(); ?>
  • 26. DISPLAY RELEASES <?php //releases posts $release_args=array( 'post_type' => 'releases', 'posts_per_page' => -1, ); $release_query = null; $release_query = new WP_Query($release_args); if( $release_query->have_posts() ) { while ($release_query->have_posts()) : $release_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <?php the_title(); ?> <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?> </article> <?php endwhile; } wp_reset_query(); ?>
  • 27. HOW DO WE SHOW ARTISTS WITH RELEASES?
  • 28. <?php //artists posts $artist_args=array( 'post_type' => 'artists', DISPLAY 'posts_per_page' => -1, ARTISTS ); $artist_query = null; $artist_query = new WP_Query($artist_args); if( $artist_query->have_posts() ) { while ($artist_query->have_posts()) : $artist_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <h2><?php the_title(); ?></h2> <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> <?php the_excerpt(); ?> //insert releases here </article> <?php endwhile; } wp_reset_query(); ?>
  • 29. while ($artist_query->have_posts()) : $artist_query->the_post(); ?> DISPLAY <article> <?php the_post_thumbnail(); ?> ARTISTS <h2><?php the_title(); ?></h2> <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> <?php the_excerpt(); ?> <?php //releases posts $release_args=array( 'post_type' => 'releases', 'posts_per_page' => -1, DISPLAY ); $release_query = null; RELEASES $release_query = new WP_Query($release_args); if( $release_query->have_posts() ) { while ($release_query->have_posts()) : $release_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <?php the_title(); ?> <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ? </article> <?php endwhile; } wp_reset_query(); ?> </article>
  • 30. while ($artist_query->have_posts()) : $artist_query->the_post(); ?> DISPLAY <article> <?php the_post_thumbnail(); ?> ARTISTS <h2><?php the_title(); ?></h2> <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> <?php the_excerpt(); ?> GET ARTIST TITLE <?php //releases posts $release_args=array( 'post_type' => 'releases', 'posts_per_page' => -1, ); DISPLAY $release_query = null; $release_query = new WP_Query($release_args); RELEASES if( $release_query->have_posts() ) { while ($release_query->have_posts()) : $release_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <?php the_title(); ?> <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ? </article>
  • 31. while ($artist_query->have_posts()) : $artist_query->the_post(); ?> DISPLAY <article> <?php the_post_thumbnail(); ?> ARTISTS <h2><?php the_title(); ?></h2> <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> <?php the_excerpt(); ?> GET ARTIST TITLE <?php $tax_artist = get_the_title(); ?> <?php //releases posts $release_args=array( 'post_type' => 'releases', 'posts_per_page' => -1, ); DISPLAY $release_query = null; $release_query = new WP_Query($release_args); RELEASES if( $release_query->have_posts() ) { while ($release_query->have_posts()) : $release_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <?php the_title(); ?> <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ? </article>
  • 32. while ($artist_query->have_posts()) : $artist_query->the_post(); ?> DISPLAY <article> <?php the_post_thumbnail(); ?> ARTISTS <h2><?php the_title(); ?></h2> <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> <?php the_excerpt(); ?> GET ARTIST TITLE <?php $tax_artist = get_the_title(); ?> <?php //releases posts $release_args=array( 'post_type' => 'releases', $taxonomy => $term 'artists' => $tax_artist, 'posts_per_page' => -1, ); $release_query = null; $release_query = new WP_Query($release_args); if( $release_query->have_posts() ) { DISPLAY while ($release_query->have_posts()) : $release_query->the_post(); ?> RELEASES <article> <?php the_post_thumbnail(); ?> <?php the_title(); ?> <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ? </article>
  • 33. <?php //artists posts $artist_args=array( 'post_type' => 'artists', START ); 'posts_per_page' => -1, ARTISTS $artist_query = null; $artist_query = new WP_Query($artist_args); QUERY if( $artist_query->have_posts() ) { while ($artist_query->have_posts()) : $artist_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <h2><?php the_title(); ?></h2> <?php echo get_the_term_list( $post->ID, ‘locations’, ‘From: ’, ‘ / ‘, ‘’ ); ?> <?php the_excerpt(); ?> GET ARTIST TITLE <?php $tax_artist = get_the_title(); ?> <?php //releases posts $release_args=array( START RELEASES QUERY 'post_type' => 'releases', $taxonomy => $term 'artists' => $tax_artist, 'posts_per_page' => -1, ); $release_query = null; $release_query = new WP_Query($release_args); if( $release_query->have_posts() ) { while ($release_query->have_posts()) : $release_query->the_post(); ?> <article> <?php the_post_thumbnail(); ?> <?php the_title(); ?> <?php echo get_the_term_list( $post->ID, ‘release-year’, ‘(’, ‘‘, ‘)’ ); ?> </article> CLOSE RELEASES <?php endwhile; } wp_reset_query(); ?> CLOSE </article> ARTISTS <?php endwhile; } wp_reset_query(); ?>
  • 34.
  • 35. RESOURCES WordPress Codex & Forums http://codex.wordpress.org/ http://wordpress.org/support/ Register Custom Post Types http://codex.wordpress.org/Function_Reference/register_post_type Register Taxonomies http://codex.wordpress.org/Function_Reference/register_taxonomy Query Posts http://codex.wordpress.org/Function_Reference/query_posts The Loop http://codex.wordpress.org/The_Loop
  • 36. RESOURCES Plugins CPT-onomies: Using Custom Post Types as Taxonomies http://wordpress.org/extend/plugins/cpt-onomies/
  • 37. DEMYSTIFYING CUSTOM POST TYPES & TAXONOMIES Tracey Kemp @dogshindleg Full code samples and explanations dogshindleg.com