SlideShare una empresa de Scribd logo
1 de 44
Custom Post Types in WordPress 3.x Setup, Customization and Useage Scenarios Morten Rand-Hendriksen Creative Director, Pink & Yellow Media www.designisphilosophy.com Twitter: @mor10 HELLO,MY NAME IS MOR10people tend to spell it with an ‘o’, but that’s just plain wrong
WordPress Developers Unite! ! Not your regular WordCamp Speakers announced today Tickets: $85www.wordcampdevelopers.com
Like “regular” WordPress posts, but handled separately. Custom single template Custom index page Custom taxonomies (categories and tags) Custom taxonomy indexes Advanced custom queries WHAT ARE CUSTOM POST TYPES ?
CREATING A NEW CUSTOM POST TYPE #
// Add new post type for Shoots add_action('init', 'adley_shoots_init'); function adley_shoots_init()  {    $labels = array( … stuff … );     $args = array( … stuff … );  register_post_type('shoot',$args); } CREATING A NEW CUSTOM POST TYPE #
$labels = array(     'name' => _x('Shoots', 'general name'),     'singular_name' => _x('Shoot', 'singular name'),     'add_new' => _x('Add new shoot', 'shoot'),     'add_new_item' => __('Add new shoot'),     'edit_item' => __('Edit shoot'),     'new_item' => __('New shoot'),     'view_item' => __('View shoot'),     'search_items' => __('Search shoots'),     'not_found' =>  __('No shoots found'),     'not_found_in_trash' => __('No shoots found in trash'),      'parent_item_colon' => ''   ); CREATING A NEW CUSTOM POST TYPE #
$args = array(     'labels' => $labels,     'public' => true,     'publicly_queryable' => true,     'show_ui' => true,      'query_var' => true,     'rewrite' => true,     'capability_type' => 'post',     'hierarchical' => false,     'menu_position' => null,     'supports' => array('title','editor','author','thumbnail','excerpt','comments'),     'has_archive' => 'shoots'   );  CREATING A NEW CUSTOM POST TYPE #
CREATING A NEW CUSTOM POST TYPE #
CREATING CUSTOM TAXONOMIES #
// Add taxonomies for Shoots add_action( 'init', 'adley_create_taxonomies', 0 ); function adley_create_taxonomies()  {     $labels = array( … stuff …);  register_taxonomy('topics','shoot',array(        … stuff            )    ); } CREATING CUSTOM TAXONOMIES #
$labels = array( 'name' => _x( 'Topics', 'taxonomy general name' ), 'singular_name' => _x( 'Topic', 'taxonomy singular name' ), 'search_items' =>  __( 'Search by topic' ), 'all_items' => __( 'All topics' ), 'most_used_items' => null, 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Change topic' ),  'update_item' => __( 'Update topic' ), 'add_new_item' => __( 'Add new topic' ), 'new_item_name' => __( 'New topic' ), 'menu_name' => __( 'Topics' ), ); CREATING CUSTOM TAXONOMIES #
register_taxonomy('topics','shoot',array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'topics' ) )); CREATING CUSTOM TAXONOMIES #
CUSTOM POST TYPE ICONS ?
http://randyjensenonline.com/thoughts/ wordpress-custom-post-type-fugue-icons/
// Adds custom icon to the Shoots tab add_action( 'admin_head', 'cpt_icons' ); function cpt_icons() {     ?>     <style type="text/css" media="screen">         #menu-posts-shoot .wp-menu-image {             background: url(<?phpbloginfo('template_url')            ?>/images/photo-album.png) no-repeat 6px –           17px !important;         }         #menu-posts-shoot:hover .wp-menu-image,         #menu-posts-shoot.wp-has-current-submenu         .wp-menu-image {             background-position:6px 7px!important;         }     </style> <?php } CUSTOM POST TYPE ICONS #
// Adds custom icon to the Shoots tab add_action( 'admin_head', 'cpt_icons' ); function cpt_icons() {     ?>     <style type="text/css" media="screen">         #menu-posts-shoot .wp-menu-image {             background: url(<?phpbloginfo('template_url')?>/images/photo-album.png) no-repeat 6px –           17px !important;         }         #menu-posts-shoot:hover .wp-menu-image,        #menu-posts-shoot.wp-has-current-submenu         .wp-menu-image {             background-position:6px 7px!important;         }     </style> <?php } CUSTOM POST TYPE ICONS #
// Adds custom icon to the Shoots tab add_action( 'admin_head', 'cpt_icons' ); function cpt_icons() {     ?>     <style type="text/css" media="screen">         #menu-posts-shoot .wp-menu-image {             background: url(<?phpbloginfo('template_url')?>/images/photo-album.png) no-repeat 6px –           17px !important;         }         #menu-posts-shoot:hover .wp-menu-image,        #menu-posts-shoot.wp-has-current-submenu         .wp-menu-image {             background-position:6px 7px!important;         }     </style> <?php } CUSTOM POST TYPE ICONS #
For single pages: single-postType.php For taxonomy pages: taxonomy.php For index page(s) (new in 3.1): archive-postType.php CUSTOM POST TYPE PAGES ?
$args = array(     'labels' => $labels,     'public' => true,     'publicly_queryable' => true,     'show_ui' => true,      'query_var' => true,     'rewrite' => true,     'capability_type' => 'post',     'hierarchical' => false,     'menu_position' => null,     'supports' => array('title','editor','author','thumbnail','excerpt','comments'),     'has_archive' => 'shoots'   );  CUSTOM POST TYPE PAGES ?
CUSTOM POST TYPE PAGES ?
CUSTOM POST TYPE PAGES ?
CUSTOM POST TYPE PAGES ?
CUSTOM POST TYPE PAGES ?
single-soknad.php archive-soknad.php taxonomy.php
“FUN” WITH QUERIES #
Get the object term (taxonomy value) <?php $terms = wp_get_object_terms(  $post->ID,  'soknadsstatus',  'fields=names‘ ); $status = implode(', ', $terms); ?> “FUN” WITH QUERIES # Taxonomy slug all, ids, names or all_with_object_id
Create list if term items (categories) <?php $kommuneterm =  get_terms('kommune', 'orderby=name‘); ?> <ul> <?phpforeach ($kommuneterm as $sted) { ?> <li><a href=“<?php echo get_term_link( $sted->slug, 'kommune‘ );?>"> <?phpecho $sted->name; ?> (<?php echo $sted->count; ?>)</a></li> <?php} ?> </ul> “FUN” WITH QUERIES #
EXPAND YOUR HORIZONS ? Make Web Not WarSaturday May 7th www.webnotwar.ca
WordPress Developers Unite! ! Not your regular WordCamp Speakers announced today Tickets: $85www.wordcampdevelopers.com
Morten Rand-Hendriksen Creative Director, Pink & Yellow Media www.designisphilosophy.com @mor10 www.pinkandyellow.com designisphilosophy.com/facebook GETINTOUCH

Más contenido relacionado

La actualidad más candente

Haml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web DevelopmentHaml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web Developmentjeremyw
 
Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)baronmunchowsen
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management SystemValent Mustamin
 
Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mike Schinkel
 
Custom content types &amp; custom taxonomies in wordpress
Custom content types &amp; custom taxonomies in wordpressCustom content types &amp; custom taxonomies in wordpress
Custom content types &amp; custom taxonomies in wordpressstimasoft
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta FieldsLiton Arefin
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapАндрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapDrupalSPB
 
CSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the BackendCSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the BackendFITC
 
Accelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemAccelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemWynn Netherland
 
WordPress 15th Meetup - Build a Theme
WordPress 15th Meetup - Build a ThemeWordPress 15th Meetup - Build a Theme
WordPress 15th Meetup - Build a ThemeFadi Nicolas Zahhar
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricksambiescent
 
7 reasons why developers should love Joomla!
7 reasons why developers should love Joomla!7 reasons why developers should love Joomla!
7 reasons why developers should love Joomla!Bartłomiej Krztuk
 
WordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme buildingWordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme buildingJonny Allbut
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Balázs Tatár
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3 Wynn Netherland
 

La actualidad más candente (20)

Haml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web DevelopmentHaml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web Development
 
Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management System
 
Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012Mastering Custom Post Types - WordCamp Atlanta 2012
Mastering Custom Post Types - WordCamp Atlanta 2012
 
JQuery Basics
JQuery BasicsJQuery Basics
JQuery Basics
 
Custom content types &amp; custom taxonomies in wordpress
Custom content types &amp; custom taxonomies in wordpressCustom content types &amp; custom taxonomies in wordpress
Custom content types &amp; custom taxonomies in wordpress
 
Custom Post Types and Meta Fields
Custom Post Types and Meta FieldsCustom Post Types and Meta Fields
Custom Post Types and Meta Fields
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapАндрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
 
CSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the BackendCSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the Backend
 
Quality code by design
Quality code by designQuality code by design
Quality code by design
 
Accelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemAccelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gem
 
WordPress 15th Meetup - Build a Theme
WordPress 15th Meetup - Build a ThemeWordPress 15th Meetup - Build a Theme
WordPress 15th Meetup - Build a Theme
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
7 reasons why developers should love Joomla!
7 reasons why developers should love Joomla!7 reasons why developers should love Joomla!
7 reasons why developers should love Joomla!
 
WordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme buildingWordCamp Bristol 2019 - WordPress custom theme building
WordCamp Bristol 2019 - WordPress custom theme building
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
 
Php My Sql
Php My SqlPhp My Sql
Php My Sql
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 

Destacado

Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noMorten Rand-Hendriksen
 
Your Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos SuckYour Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos SuckMorten Rand-Hendriksen
 
10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your SiteMorten Rand-Hendriksen
 
Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015Morten Rand-Hendriksen
 
Empathy and Acceptance in Design and Community
Empathy and Acceptance in Design and CommunityEmpathy and Acceptance in Design and Community
Empathy and Acceptance in Design and CommunityMorten Rand-Hendriksen
 

Destacado (6)

Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.no
 
Your Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos SuckYour Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos Suck
 
10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site
 
Ethics and the Promise of Open Source
Ethics and the Promise of Open SourceEthics and the Promise of Open Source
Ethics and the Promise of Open Source
 
Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015
 
Empathy and Acceptance in Design and Community
Empathy and Acceptance in Design and CommunityEmpathy and Acceptance in Design and Community
Empathy and Acceptance in Design and Community
 

Similar a Wp meetup custom post types

Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised contentMichael Peacock
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsTomAuger
 
Custom Post Types and Taxonomies in WordPress
Custom Post Types and Taxonomies in WordPressCustom Post Types and Taxonomies in WordPress
Custom Post Types and Taxonomies in WordPressBrad Williams
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPressNick La
 
Introduction To Moco
Introduction To MocoIntroduction To Moco
Introduction To MocoNaoya Ito
 
HTML::FormHandler
HTML::FormHandlerHTML::FormHandler
HTML::FormHandlerbbeeley
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helperslicejack
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentTammy Hart
 
WordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksWordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksJohn Pratt
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)Beau Lebens
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress sitereferences
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterCodeIgniter Conference
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel MakhrinskyDrupalCampDN
 
Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)Kris Wallsmith
 

Similar a Wp meetup custom post types (20)

WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised content
 
Sencha Touch Intro
Sencha Touch IntroSencha Touch Intro
Sencha Touch Intro
 
WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
 
Custom Post Types and Taxonomies in WordPress
Custom Post Types and Taxonomies in WordPressCustom Post Types and Taxonomies in WordPress
Custom Post Types and Taxonomies in WordPress
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPress
 
Introduction To Moco
Introduction To MocoIntroduction To Moco
Introduction To Moco
 
HTML::FormHandler
HTML::FormHandlerHTML::FormHandler
HTML::FormHandler
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helper
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
WordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksWordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme Hacks
 
Assetic (Zendcon)
Assetic (Zendcon)Assetic (Zendcon)
Assetic (Zendcon)
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniter
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
PHP
PHP PHP
PHP
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel Makhrinsky
 
Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)
 

Más de Morten Rand-Hendriksen

Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Morten Rand-Hendriksen
 
How Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and TechnologyHow Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and TechnologyMorten Rand-Hendriksen
 
How to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web DesignHow to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web DesignMorten Rand-Hendriksen
 
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017Morten Rand-Hendriksen
 
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017Morten Rand-Hendriksen
 
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017Morten Rand-Hendriksen
 

Más de Morten Rand-Hendriksen (8)

How to Build Custom WordPress Blocks
How to Build Custom WordPress BlocksHow to Build Custom WordPress Blocks
How to Build Custom WordPress Blocks
 
Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0
 
How Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and TechnologyHow Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and Technology
 
How to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web DesignHow to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web Design
 
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
 
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
 
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
 
GitHub for the Rest of Us
GitHub for the Rest of UsGitHub for the Rest of Us
GitHub for the Rest of Us
 

Último

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 

Último (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Wp meetup custom post types

  • 1. Custom Post Types in WordPress 3.x Setup, Customization and Useage Scenarios Morten Rand-Hendriksen Creative Director, Pink & Yellow Media www.designisphilosophy.com Twitter: @mor10 HELLO,MY NAME IS MOR10people tend to spell it with an ‘o’, but that’s just plain wrong
  • 2. WordPress Developers Unite! ! Not your regular WordCamp Speakers announced today Tickets: $85www.wordcampdevelopers.com
  • 3. Like “regular” WordPress posts, but handled separately. Custom single template Custom index page Custom taxonomies (categories and tags) Custom taxonomy indexes Advanced custom queries WHAT ARE CUSTOM POST TYPES ?
  • 4.
  • 5. CREATING A NEW CUSTOM POST TYPE #
  • 6. // Add new post type for Shoots add_action('init', 'adley_shoots_init'); function adley_shoots_init() { $labels = array( … stuff … ); $args = array( … stuff … ); register_post_type('shoot',$args); } CREATING A NEW CUSTOM POST TYPE #
  • 7. $labels = array( 'name' => _x('Shoots', 'general name'), 'singular_name' => _x('Shoot', 'singular name'), 'add_new' => _x('Add new shoot', 'shoot'), 'add_new_item' => __('Add new shoot'), 'edit_item' => __('Edit shoot'), 'new_item' => __('New shoot'), 'view_item' => __('View shoot'), 'search_items' => __('Search shoots'), 'not_found' => __('No shoots found'), 'not_found_in_trash' => __('No shoots found in trash'), 'parent_item_colon' => '' ); CREATING A NEW CUSTOM POST TYPE #
  • 8. $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','author','thumbnail','excerpt','comments'), 'has_archive' => 'shoots' ); CREATING A NEW CUSTOM POST TYPE #
  • 9. CREATING A NEW CUSTOM POST TYPE #
  • 10.
  • 11.
  • 12.
  • 14. // Add taxonomies for Shoots add_action( 'init', 'adley_create_taxonomies', 0 ); function adley_create_taxonomies() { $labels = array( … stuff …); register_taxonomy('topics','shoot',array( … stuff ) ); } CREATING CUSTOM TAXONOMIES #
  • 15. $labels = array( 'name' => _x( 'Topics', 'taxonomy general name' ), 'singular_name' => _x( 'Topic', 'taxonomy singular name' ), 'search_items' => __( 'Search by topic' ), 'all_items' => __( 'All topics' ), 'most_used_items' => null, 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Change topic' ), 'update_item' => __( 'Update topic' ), 'add_new_item' => __( 'Add new topic' ), 'new_item_name' => __( 'New topic' ), 'menu_name' => __( 'Topics' ), ); CREATING CUSTOM TAXONOMIES #
  • 16. register_taxonomy('topics','shoot',array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'topics' ) )); CREATING CUSTOM TAXONOMIES #
  • 17.
  • 18.
  • 19. CUSTOM POST TYPE ICONS ?
  • 21.
  • 22. // Adds custom icon to the Shoots tab add_action( 'admin_head', 'cpt_icons' ); function cpt_icons() { ?> <style type="text/css" media="screen"> #menu-posts-shoot .wp-menu-image { background: url(<?phpbloginfo('template_url') ?>/images/photo-album.png) no-repeat 6px – 17px !important; } #menu-posts-shoot:hover .wp-menu-image, #menu-posts-shoot.wp-has-current-submenu .wp-menu-image { background-position:6px 7px!important; } </style> <?php } CUSTOM POST TYPE ICONS #
  • 23. // Adds custom icon to the Shoots tab add_action( 'admin_head', 'cpt_icons' ); function cpt_icons() { ?> <style type="text/css" media="screen"> #menu-posts-shoot .wp-menu-image { background: url(<?phpbloginfo('template_url')?>/images/photo-album.png) no-repeat 6px – 17px !important; } #menu-posts-shoot:hover .wp-menu-image, #menu-posts-shoot.wp-has-current-submenu .wp-menu-image { background-position:6px 7px!important; } </style> <?php } CUSTOM POST TYPE ICONS #
  • 24. // Adds custom icon to the Shoots tab add_action( 'admin_head', 'cpt_icons' ); function cpt_icons() { ?> <style type="text/css" media="screen"> #menu-posts-shoot .wp-menu-image { background: url(<?phpbloginfo('template_url')?>/images/photo-album.png) no-repeat 6px – 17px !important; } #menu-posts-shoot:hover .wp-menu-image, #menu-posts-shoot.wp-has-current-submenu .wp-menu-image { background-position:6px 7px!important; } </style> <?php } CUSTOM POST TYPE ICONS #
  • 25. For single pages: single-postType.php For taxonomy pages: taxonomy.php For index page(s) (new in 3.1): archive-postType.php CUSTOM POST TYPE PAGES ?
  • 26. $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','author','thumbnail','excerpt','comments'), 'has_archive' => 'shoots' ); CUSTOM POST TYPE PAGES ?
  • 27. CUSTOM POST TYPE PAGES ?
  • 28. CUSTOM POST TYPE PAGES ?
  • 29. CUSTOM POST TYPE PAGES ?
  • 30. CUSTOM POST TYPE PAGES ?
  • 31.
  • 32.
  • 33.
  • 36.
  • 37.
  • 38.
  • 39. Get the object term (taxonomy value) <?php $terms = wp_get_object_terms( $post->ID, 'soknadsstatus', 'fields=names‘ ); $status = implode(', ', $terms); ?> “FUN” WITH QUERIES # Taxonomy slug all, ids, names or all_with_object_id
  • 40.
  • 41. Create list if term items (categories) <?php $kommuneterm = get_terms('kommune', 'orderby=name‘); ?> <ul> <?phpforeach ($kommuneterm as $sted) { ?> <li><a href=“<?php echo get_term_link( $sted->slug, 'kommune‘ );?>"> <?phpecho $sted->name; ?> (<?php echo $sted->count; ?>)</a></li> <?php} ?> </ul> “FUN” WITH QUERIES #
  • 42. EXPAND YOUR HORIZONS ? Make Web Not WarSaturday May 7th www.webnotwar.ca
  • 43. WordPress Developers Unite! ! Not your regular WordCamp Speakers announced today Tickets: $85www.wordcampdevelopers.com
  • 44. Morten Rand-Hendriksen Creative Director, Pink & Yellow Media www.designisphilosophy.com @mor10 www.pinkandyellow.com designisphilosophy.com/facebook GETINTOUCH

Notas del editor

  1. The header text can be replaced with this simple block of code. Simple…
  2. The header text can be replaced with this simple block of code. Simple…
  3. The header text can be replaced with this simple block of code. Simple…
  4. The header text can be replaced with this simple block of code. Simple…
  5. The header text can be replaced with this simple block of code. Simple…
  6. The header text can be replaced with this simple block of code. Simple…
  7. The header text can be replaced with this simple block of code. Simple…
  8. The header text can be replaced with this simple block of code. Simple…
  9. The header text can be replaced with this simple block of code. Simple…
  10. The header text can be replaced with this simple block of code. Simple…
  11. The header text can be replaced with this simple block of code. Simple…
  12. The header text can be replaced with this simple block of code. Simple…
  13. The header text can be replaced with this simple block of code. Simple…
  14. The header text can be replaced with this simple block of code. Simple…
  15. The header text can be replaced with this simple block of code. Simple…
  16. The header text can be replaced with this simple block of code. Simple…
  17. The header text can be replaced with this simple block of code. Simple…
  18. The header text can be replaced with this simple block of code. Simple…
  19. The header text can be replaced with this simple block of code. Simple…
  20. The header text can be replaced with this simple block of code. Simple…
  21. The header text can be replaced with this simple block of code. Simple…
  22. The header text can be replaced with this simple block of code. Simple…
  23. The header text can be replaced with this simple block of code. Simple…
  24. The header text can be replaced with this simple block of code. Simple…
  25. The header text can be replaced with this simple block of code. Simple…
  26. The header text can be replaced with this simple block of code. Simple…
  27. The header text can be replaced with this simple block of code. Simple…
  28. The header text can be replaced with this simple block of code. Simple…
  29. The header text can be replaced with this simple block of code. Simple…
  30. The header text can be replaced with this simple block of code. Simple…
  31. The header text can be replaced with this simple block of code. Simple…
  32. The header text can be replaced with this simple block of code. Simple…
  33. The header text can be replaced with this simple block of code. Simple…
  34. The header text can be replaced with this simple block of code. Simple…
  35. The header text can be replaced with this simple block of code. Simple…
  36. The header text can be replaced with this simple block of code. Simple…
  37. The header text can be replaced with this simple block of code. Simple…
  38. The header text can be replaced with this simple block of code. Simple…
  39. The header text can be replaced with this simple block of code. Simple…
  40. The header text can be replaced with this simple block of code. Simple…
  41. The header text can be replaced with this simple block of code. Simple…
  42. The header text can be replaced with this simple block of code. Simple…
  43. The header text can be replaced with this simple block of code. Simple…
  44. The header text can be replaced with this simple block of code. Simple…