SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
Wynn Netherland
 

Tendances (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
 

En vedette

En vedette (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
 

Similaire à Wp meetup custom post types

Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised content
Michael Peacock
 
Introduction To Moco
Introduction To MocoIntroduction To Moco
Introduction To Moco
Naoya Ito
 
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
Tammy Hart
 
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
references
 
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniter
CodeIgniter Conference
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel Makhrinsky
DrupalCampDN
 

Similaire à 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)
 

Plus de Morten Rand-Hendriksen

Plus 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
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

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

Notes de l'éditeur

  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…