Top Banner
Wordpress Custom Contents Enrico Corinti #KC2011 lunedì 21 marzo 2011
31

Wordpress Custom Contents

Jan 27, 2015

Download

Technology

Enrico Corinti

Il mio intervento al WordCamp2011 di Modena
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Wordpress Custom Contents

Wordpress Custom Contents

Enrico Corinti

#KC2011

lunedì 21 marzo 2011

Page 2: Wordpress Custom Contents

Chi sono

• Enrico Corinti, 34 anni, Ascoli Piceno

• Web Developer/Wordpress Fan

• http://www.webeing.net/code

• @enricocorinti

lunedì 21 marzo 2011

Page 3: Wordpress Custom Contents

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

Page 4: Wordpress Custom Contents

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

Page 5: Wordpress Custom Contents

Make it custom!

lunedì 21 marzo 2011

Page 6: Wordpress Custom Contents

Make it custom! Post Types (CPT)

• Contenuto: aggregazione di informazioni multimediali necessarie a descrivere ad un dato

lunedì 21 marzo 2011

Page 7: Wordpress Custom Contents

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

Page 8: Wordpress Custom Contents

Make it custom! Write Panels

• Excerpt

• Custom Fields

• Discussion

• Author

• Revisions

• ...

• Book Author

• Address

• Email

• Price

• ...

lunedì 21 marzo 2011

Page 9: Wordpress Custom Contents

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

Page 10: Wordpress Custom Contents

Make it custom! Taxonomies

• Categories

• Tags

• Link Categories

• Book Genre

• Product Versions

• Document type

• ...

lunedì 21 marzo 2011

Page 11: Wordpress Custom Contents

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

Page 13: Wordpress Custom Contents

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

Page 14: Wordpress Custom Contents

• Labels

• Supports (Write Panels)

• Rewrite

• Taxonomies

• ...

Register Post Type - Altri parametri

http://codex.wordpress.org/Function_Reference/register_post_type

lunedì 21 marzo 2011

Page 15: Wordpress Custom Contents

Add Meta Boxes

//Preparo il mio boxfunction wc11_author_info_box() {

//... elementi HTML del box}

lunedì 21 marzo 2011

Page 16: Wordpress Custom Contents

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

Page 17: Wordpress Custom Contents

Add Meta Boxes

//Preparo le azioni da fare al salvataggiofunction save_postdata( $post_id ) {

//...operazioni da fare al salvataggio}

lunedì 21 marzo 2011

Page 18: Wordpress Custom Contents

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

Page 19: Wordpress Custom Contents

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

Page 20: Wordpress Custom Contents

• Labels

• Hierarchical

• show_in_nav_menus

• show_tagcloud

• ...

Register Taxonomy - Altri parametri

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

lunedì 21 marzo 2011

Page 21: Wordpress Custom Contents

Let it Views!

lunedì 21 marzo 2011

Page 22: Wordpress Custom Contents

New Templates Hierarchy

lunedì 21 marzo 2011

Page 23: Wordpress Custom Contents

New Templates Hierarchy

lunedì 21 marzo 2011

Page 24: Wordpress Custom Contents

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

Page 25: Wordpress Custom Contents

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

Page 26: Wordpress Custom Contents

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

Page 27: Wordpress Custom Contents

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

Page 28: Wordpress Custom Contents

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

Page 29: Wordpress Custom Contents

Take it easy... Plugins

•More...

• Fields,

• Types,

• Taxonomies

•Custom UI

•WP Post Formats

lunedì 21 marzo 2011

Page 31: Wordpress Custom Contents

Grazie! :)

@enricocorinti

http://www.webeing.net/code

[email protected]

lunedì 21 marzo 2011