Enrico Corinti, WordPress Custom Contents
-
Upload
knowcamp -
Category
Technology
-
view
1.202 -
download
2
description
Transcript of Enrico Corinti, WordPress Custom Contents
Wordpress Custom Contents
Enrico Corinti
#KC2011
lunedì 21 marzo 2011
Chi sono
• Enrico Corinti, 34 anni, Ascoli Piceno
• Web Developer/Wordpress Fan
• http://www.webeing.net/code
• @enricocorinti
lunedì 21 marzo 2011
Argomenti• Make it Custom!
• Custom Post Types
• Custom Write Panels
• Custom Taxonomies
• Let it Views!
• Custom Templating
• Post Formats (Hot! 3.1)
• Un esempio: Slides - Autori (#kc2011)lunedì 21 marzo 2011
Wordpress Custom is better!
• Completa separazione di concetti e contenuti
• Write Panels differenziati e customizzati per la gestione di contenuti differenti
• Valore semantico al contenuto
• Completa separazione dei templates e views
• Custom Permalinks
• Wordpress per blogger o Wordpress come CMS?
lunedì 21 marzo 2011
Make it custom!
lunedì 21 marzo 2011
Make it custom! Post Types (CPT)
• Contenuto: aggregazione di informazioni multimediali necessarie a descrivere ad un dato
lunedì 21 marzo 2011
Make it custom! Post Types (CPT)
• Post
• Pages
• Attachment (media)
• Revisions
• Nav Menus (WP 3.x)
• [Links]
• Books
• Authors
• Products
• Video
• Events
• ...
lunedì 21 marzo 2011
Make it custom! Write Panels
• Excerpt
• Custom Fields
• Discussion
• Author
• Revisions
• ...
• Book Author
• Address
• Price
• ...
lunedì 21 marzo 2011
Make it custom! Taxonomies
• Tassonomia: classificazione gerarchica di concetti (o dati) necessaria a stabilire un ordine nella catalogazione degli stessi.
• Utile per categorizzare molteplici informazioni e classificare i contenuti in un CMS, ad esempio per conferire un ordine di lettura strutturato
lunedì 21 marzo 2011
Make it custom! Taxonomies
• Categories
• Tags
• Link Categories
• Book Genre
• Product Versions
• Document type
• ...
lunedì 21 marzo 2011
Make it custom! Formats (3.1)
• Categorizzare la rappresentazioni dei post
• Customizzare i templates
• Miscuglio di concetti e confusione nella creazione dei contenuti
• Aside
• Gallery
• Link
• Image
• Quote
• Status
• Video
• Audio
• Chat
lunedì 21 marzo 2011
Andiamo nel pratico
http://wordcamp.essereweb.netUser: guest
Passwd: guest
lunedì 21 marzo 2011
Register Post Type
add_action('init', 'create_wc11_slides_type');function create_wc11_slides_type() { register_post_type( 'wc11_slides', 'public' => true,
'has_archive' => true, );}
lunedì 21 marzo 2011
• Labels
• Supports (Write Panels)
• Rewrite
• Taxonomies
• ...
Register Post Type - Altri parametri
http://codex.wordpress.org/Function_Reference/register_post_type
lunedì 21 marzo 2011
Add Meta Boxes
//Preparo il mio boxfunction wc11_author_info_box() {
//... elementi HTML del box}
lunedì 21 marzo 2011
Add Meta Boxes
//Aggiungiamo il boxfunction create_wc11_author_info_box() { add_meta_box(
'wc11_author_box_id', ‘Dati Autore’, 'wc11_author_info_box', 'wc11_authors' );
}
lunedì 21 marzo 2011
Add Meta Boxes
//Preparo le azioni da fare al salvataggiofunction save_postdata( $post_id ) {
//...operazioni da fare al salvataggio}
lunedì 21 marzo 2011
Add Meta Boxes
//Hook Actions in Wordpress
// WP 3.0+add_action('add_meta_boxes','wc11_author_info_box');
// backwards compatibleadd_action('admin_init', 'wc11_author_info_box', 1);
/* Do something with the data entered */add_action('save_post', 'save_postdata');
lunedì 21 marzo 2011
Register Taxonomy//Registro la mia nuova tassonomiafunction create_wc11_slide_taxonomies() {register_taxonomy('wc11_topic_areas','wc11_slides’,
array('query_var' => true,'rewrite' => array( 'slug' => 'slides' )));
}//hook into the init actionadd_action('init',’create_wc11_slide_taxonomies', 0 );
lunedì 21 marzo 2011
• Labels
• Hierarchical
• show_in_nav_menus
• show_tagcloud
• ...
Register Taxonomy - Altri parametri
http://codex.wordpress.org/Function_Reference/register_taxonomy
lunedì 21 marzo 2011
Let it Views!
lunedì 21 marzo 2011
New Templates Hierarchy
lunedì 21 marzo 2011
New Templates Hierarchy
lunedì 21 marzo 2011
Template Functions<?php//Elenco dei CPT
get_post_types( $args, $output, $operator );
//Tipo di contenuto associato al post get_post_type($post->ID);
//Conditional Function for archivesis_post_type_archive( $post_types );
lunedì 21 marzo 2011
Template Functions<?php//Tagcloud wp_tag_cloud( array( 'taxonomy' => 'taxonomy_name' ) );
//Liste e Dropdown $args = array( 'taxonomy' => 'taxonomy_name' ) ;wp_list_categories( $args ); wp_dropdown_categories( $args );
?>
lunedì 21 marzo 2011
Template Functions<?php //Array - Elenco completo$terms = get_terms( $taxonomies, $args ); foreach ( $terms as $term ) { … }
//Elenco di link filtrato per IDget_the_term_list( $id , $taxonomy );
//Array filtrato per ID$terms = get_the_terms( $id , $taxonomy ); foreach ( $terms as $term ) { … }
?>
lunedì 21 marzo 2011
Post Formats
•Meta-informazioni aggiuntive associate al post
•Un nuovo modo per semplificare e diversificare la presentazione dei contenuti
•Un modo alternativo alle tassonomie per presentare lo stesso contenuto in modi differenti
lunedì 21 marzo 2011
Post Formats//Add theme capability to manage formatsadd_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
//Check formatsif ( has_post_format( 'aside' )) { //Faccio qualcosa per lo “stile” Aside}
//Built-in “post_class()” add a “format-aside” class to our theme classes<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
lunedì 21 marzo 2011
Take it easy... Plugins
•More...
• Fields,
• Types,
• Taxonomies
•Custom UI
•WP Post Formats
lunedì 21 marzo 2011
References
• http://codex.wordpress.org/Post_Types#Custom_Types
• http://codex.wordpress.org/Function_Reference/register_taxonomy
• http://kovshenin.com/archives/custom-post-types-in-wordpress-3-0/
• http://blog.artera.it/cms/wordpress-3-1-post-formats
• http://www.slideshare.net/miziomon/custom-taxonomies-custom-post-type
lunedì 21 marzo 2011
Grazie! :)
@enricocorinti
http://www.webeing.net/code
lunedì 21 marzo 2011