SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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)
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
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
 
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
 
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
 
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
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Kürzlich hochgeladen (20)

Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
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
 
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
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

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

Hinweis der Redaktion

  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…