SlideShare a Scribd company logo
1 of 86
Download to read offline
Crea un tema compatibile
con le ultime novità
WordPress
Attento a queste
icone ;-)
skillsandmore.org/wctrn-theme
mentor - developer - writer
Chi sono e cosa faccio
Chi sono e cosa faccio
skillsandmore.org/wordpress-inbound-marketing
facciamo conoscere il
brand
I loghi
//Agganciati ad after_setup_theme
add_theme_support( 'custom-logo' );
Aggiungi il supporto
Aspetta...
C’è molto di più da
poter configurare!
$custom_logo = array(
'height' => 100,
'width' => 360,
'flex-height' => true,
'flex-width' => true,
);
add_theme_support( 'custom-logo', $custom_logo );
$custom_logo = array(
'height' => 100,
'width' => 360,
'flex-height' => true,
'flex-width' => true,
);
figata!
I custom header
sono una
add_theme_support(
'custom-header',
$defaults
);
$defaults = array(
'default-image' => 'path'
'header-text' => false,
'default-text-color' => '000',
'width' => 1000,
'height' => 198,
'random-default' => false,
'uploads' => false,
);
Puoi creare un
Header
Responsive
$defaults = array(
'flex-height' => false,
'flex-width' => false,
);
le immagini da usare
Suggerisci
$header = array(
'default-image' => array(
'url' => '%s/path/img.jpg',
'thumbnail_url' => '%s/path/img.jpg',
'description' => 'Immagine',
),
);
register_default_headers( $header );
$header = array(
'default-image' => array(
'url' => '%s/path/img.jpg',
'thumbnail_url' => '%s/path/img.jpg',
'description' => 'Immagine',
),
);
register_default_headers( $header );
$header = array(
'background' => array( … ),
'maglietta' => array( … ),
'scarpe' => array( … ),
);
register_default_headers( $header );
Attenzione ai percorsi!
Child theme?
$header = array(
'default-image' => array(
'url' => '%2$s/path/img.jpg',
'thumbnail_url' => '%2$s/path/img.jpg',
'description' => 'Immagine',
),
);
register_default_headers( $header );
Ora puoi
inserire video!
$defaults = array(
'default-image' => 'path'
'width' => 1000,
'height' => 198,
'flex-height' => true,
'flex-width' => true,
'video' => true
);
Come inserire i
Custom Header
nel tema?
//header.php
if ( get_header_image() ) {
the_custom_header_markup();
}
Ricordi come funziona la
Gerarchia
WordPress?
get_template_part( $slug, $name );
get_template_part( 'loop', 'index' );
get_template_part( 'loop', 'index' );
wp-content/themes/child/loop-index.php
wp-content/themes/parent/loop-index.php
wp-content/themes/child/loop.php
wp-content/themes/parent/loop.php
Come fare la stessa cosa per
JS, CSS e
immagini?
//Directory Tema Genitore
get_template_directory() . 'path';
//Directory Tema Figlio
get_stylesheet_directory() . 'path';
Perché era un
problema?
//Rimuovo script genitore
wp-dequeue-script( $handle );
//Aggiungo script figlio
wp-enqueue-script( $handle );
to the rescue!
Version 4.7
get_theme_file_uri( '/js/script.js' ),
get_theme_file_uri( '/js/script.js' ),
wp-content/themes/child/js/script.js
wp-content/themes/parent/js/script.js
i file da sovrascrivere
Limitare
get_parent_theme_file_uri('path');
//Ottengo la URL
get_theme_file_uri( 'path' );
get_parent_theme_file_uri( 'path' );
//Ottengo il percorso al file
get_theme_file_path( 'path' );
get_parent_theme_file_path( 'path' );
per modificare la gerarchia
Nuovo filtro
{$type}_template_hierarchy
//Valori possibili
404_template_hierarchy
category_template_hierarchy
author_template_hierarchy
add_filter(
'date_template_hierarchy',
function( array $templates ) {
$year = get_query_var( 'year' );
array_unshift(
$templates,
"year-{$year}.php"
);
return $templates;
} );
add_filter(
'date_template_hierarchy',
function( $templates ) {
$year = get_query_var( 'year' );
array_unshift(
$templates,
"year-{$year}.php"
);
return $templates;
} );
add_filter(
'date_template_hierarchy',
function( $templates ) {
$year = get_query_var( 'year' );
array_unshift(
$templates,
"year-{$year}.php"
);
return $templates;
} );
Personalizza la struttura
Post Template
<?php
/*
Template Name: Esempio di Post Template
*/
// Personalizza la struttura
<?php
/*
Template Name: Esempio di Post Template
Template Post Type: post, page, product
*/
// Personalizza la struttura
Rendiamolo retro
Compatibile
//Check code in examples/post-template.php!!!
function wctrn_exclude_pt( $pt ) {
if ( version_compare( $wp_version, '4.7', '<' ) ){
unset( $pt['path/pt.php'] );
}
return $pt;
}
add_filter( 'theme_page_templates', 'wctrn_exclude_pt' );
//Check code in examples/post-template.php!!!
function wctrn_exclude_pt( $pt ) {
if ( version_compare( $wp_version, '4.7', '<' ) ){
unset( $pt['path/pt.php'] );
}
return $pt;
}
add_filter( 'theme_page_templates', 'wctrn_exclude_pt' );
//Check code in examples/post-template.php!!!
function wctrn_exclude_pt( $pt ) {
if ( version_compare( $wp_version, '4.7', '<' ) ){
unset( $pt['path/pt.php'] );
}
return $pt;
}
add_filter( 'theme_page_templates', 'wctrn_exclude_pt' );
Preparare contenuto di
Esempio
add_theme_support( 'starter-content' );
$sc = array(
//Configurazione Starter Content
);
add_theme_support( 'starter_content', $sc );
$sc = array(
'widgets' => array( … ),
'posts' => array( … ),
'attachments' => array( … ),
'nav_menus' => array( … ),
'options' => array( … ),
'theme_mod' => array( … )
);
$sc = array(
'widgets' => array( … ),
'posts' => array( … ),
'attachments' => array( … ),
'nav_menus' => array( … ),
'options' => array( … ),
'theme_mod' => array( … )
);
$sc = array(
'widgets' => array(
'sidebar-1' => array(
'text_business_info',
'my_text' => array(
'title' => 'Ciao Torino!!!',
'text' => 'WordCamp'
)
)
)
);
$sc = array(
'widgets' => array( … ),
'posts' => array( … ),
'attachments' => array( … ),
'nav_menus' => array( … ),
'options' => array( … ),
'theme_mod' => array( … )
);
$sc = array(
'posts' => array(
'home',
'wctrn' => array(
'post_type' => 'page',
'post_title' => '#wctrn 2017',
'post_content' => 'Is Back!',
'thumbnail' => '{{image-wctrn}}',
'template' => 'wctrn-pt.php',
)
)
);
$sc = array(
'widgets' => array( … ),
'posts' => array( … ),
'attachments' => array( … ),
'nav_menus' => array( … ),
'options' => array( … ),
'theme_mod' => array( … )
);
$sc = array(
'attachments' => array(
'image-wctrn' => array(
'post_title' => 'WordCamp Torino',
'file' => 'images/wctrn-image.jpg'
)
)
);
$sc = array(
'attachments' => array(
'image-wctrn' => array(
'post_title' => 'WordCamp Torino',
'file' => 'images/wctrn-image.jpg'
)
)
);
'thumbnail' => '{{image-wctrn}}'
$sc = array(
'attachments' => array(
'image-wctrn' => array(
'post_title' => 'WordCamp Torino',
'file' => 'images/wctrn-image.jpg'
)
)
);
$sc = array(
'widgets' => array( … ),
'posts' => array( … ),
'attachments' => array( … ),
'nav_menus' => array( … ),
'options' => array( … ),
'theme_mod' => array( … )
);
$sc = array(
'nav_menus' => array(
'page_home' => array(
'type' => 'post_type',
'object' => 'page',
'object_id' => '{{home}}'
),
'link_sam' => array(
'title' => 'SkillsAndMore',
'url' => 'https://skillsandmore.org'
)
)
);
$sc = array(
'nav_menus' => array(
'page_home' => array(
'type' => 'post_type',
'object' => 'page',
'object_id' => '{{home}}'
),
'link_sam' => array(
'title' => 'SkillsAndMore',
'url' => 'https://skillsandmore.org'
)
)
);
'posts' => array( 'home' )
Ed è arrivato
il Customizer
function wctrn_customize_register( $wp_customize ) {
$wp_customize->add_panel();
$wp_customize->add_section();
$wp_customize->add_setting();
$wp_customize->add_control();
}
add_action( 'customize_register', 'wctrn_customize_register' );
function wctrn_customize_register( $wp_customize ) {
$wp_customize->add_panel();
$wp_customize->add_section();
$wp_customize->add_setting();
$wp_customize->add_control();
}
add_action( 'customize_register', 'wctrn_customize_register' );
$wp_customize->add_section( 'id_sezione', array(
'title' => 'Titolo sezione',
'description' => 'Descrizione sezione',
'priority' => 160,
'capability' => 'edit_theme_options',
) );
function wctrn_customize_register( $wp_customize ) {
$wp_customize->add_panel();
$wp_customize->add_section();
$wp_customize->add_setting();
$wp_customize->add_control();
}
add_action( 'customize_register', 'wctrn_customize_register' );
$wp_customize->add_setting( 'id impostazione', array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => '',
) );
function wctrn_customize_register( $wp_customize ) {
$wp_customize->add_panel();
$wp_customize->add_section();
$wp_customize->add_setting();
$wp_customize->add_control();
}
add_action( 'customize_register', 'wctrn_customize_register' );
$wp_customize->add_control( 'id_impostazione', array(
'type' => 'date',
'priority' => 10,
'section' => 'id_sezione',
'label' => 'Titolo',
'description' => 'Descrizione controllo',
'input_attrs' => array(
'class' => 'my-custom-class-for-js',
'style' => 'border: 1px solid #900',
),
) );
$wp_customize->add_control( 'id_impostazione', array(
'type' => 'date',
'priority' => 10,
'section' => 'id_sezione',
'label' => 'Titolo',
'description' => 'Descrizione controllo',
'input_attrs' => array(
'class' => 'my-custom-class-for-js',
'style' => 'border: 1px solid #900',
),
) );
->add_section( 'id_sezione'
Scorciatoie per la
Personalizzazione
$wp_customize->get_setting()->transport = 'postMessage';
$wp_customize
->get_setting( 'blogname' )
->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial()
$wp_customize
->selective_refresh
->add_partial(
'blogname',
array(
'selector' => '.site-title a',
'render_callback' => 'wctrn_atcpb',
)
);
function wctrn_atcpb(){
bloginfo('name');
}
Grazie per gli
Applausi!
Ricorda di aggiungere
la stella ;)
https://skillsandmore.org/wctrn-theme

More Related Content

What's hot

Tworzenie wtyczek dla TinyMCE 4.* - WordUp Kraków
Tworzenie wtyczek dla TinyMCE 4.* - WordUp KrakówTworzenie wtyczek dla TinyMCE 4.* - WordUp Kraków
Tworzenie wtyczek dla TinyMCE 4.* - WordUp KrakówTomasz Dziuda
 
Front-end en WordPress
Front-end en WordPressFront-end en WordPress
Front-end en WordPressDisonancias
 
WordPressのテンプレートをカスタマイズするために必要なphpを初歩から解説
WordPressのテンプレートをカスタマイズするために必要なphpを初歩から解説WordPressのテンプレートをカスタマイズするために必要なphpを初歩から解説
WordPressのテンプレートをカスタマイズするために必要なphpを初歩から解説Takashi Uemura
 
Drupal Theming Hans Rossel
Drupal Theming Hans RosselDrupal Theming Hans Rossel
Drupal Theming Hans RosselHans Rossel
 
How to Win the Heart of CSS Boys
How to Win the Heart of CSS BoysHow to Win the Heart of CSS Boys
How to Win the Heart of CSS Boys拓樹 谷
 
JS for Rails developers
JS for Rails developersJS for Rails developers
JS for Rails developersTimur Vafin
 
Form Script
Form ScriptForm Script
Form Scriptlotlot
 
スマホウェブの本命 jQueryMobile
スマホウェブの本命 jQueryMobileスマホウェブの本命 jQueryMobile
スマホウェブの本命 jQueryMobileManabu Uekusa
 
Concevoir un thème pour Wordpress
Concevoir un thème pour WordpressConcevoir un thème pour Wordpress
Concevoir un thème pour WordpressJean-Luc Houedanou
 
美团业务系统通用Ui方案
美团业务系统通用Ui方案美团业务系统通用Ui方案
美团业务系统通用Ui方案美团技术团队
 
Un juego creado en php
Un juego creado en phpUn juego creado en php
Un juego creado en phpErwin Lobo
 
Facebook app API Vs2.0
Facebook app API Vs2.0Facebook app API Vs2.0
Facebook app API Vs2.0Felix Rivas
 
Основы CSS препроцессоров и их использование в WordPress
Основы CSS препроцессоров и их использование в WordPressОсновы CSS препроцессоров и их использование в WordPress
Основы CSS препроцессоров и их использование в WordPressDmitry Mayorov
 
Drupal Cms Prezentace
Drupal Cms PrezentaceDrupal Cms Prezentace
Drupal Cms Prezentaceguest3d443e
 
Javascript and jQuery for Mobile
Javascript and jQuery for MobileJavascript and jQuery for Mobile
Javascript and jQuery for MobileIvano Malavolta
 
JavascriptMVC
JavascriptMVCJavascriptMVC
JavascriptMVC4lb0
 

What's hot (20)

Tworzenie wtyczek dla TinyMCE 4.* - WordUp Kraków
Tworzenie wtyczek dla TinyMCE 4.* - WordUp KrakówTworzenie wtyczek dla TinyMCE 4.* - WordUp Kraków
Tworzenie wtyczek dla TinyMCE 4.* - WordUp Kraków
 
Add tag shortcode
Add tag shortcodeAdd tag shortcode
Add tag shortcode
 
Front-end en WordPress
Front-end en WordPressFront-end en WordPress
Front-end en WordPress
 
WordPressのテンプレートをカスタマイズするために必要なphpを初歩から解説
WordPressのテンプレートをカスタマイズするために必要なphpを初歩から解説WordPressのテンプレートをカスタマイズするために必要なphpを初歩から解説
WordPressのテンプレートをカスタマイズするために必要なphpを初歩から解説
 
Drupal Theming Hans Rossel
Drupal Theming Hans RosselDrupal Theming Hans Rossel
Drupal Theming Hans Rossel
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
How to Win the Heart of CSS Boys
How to Win the Heart of CSS BoysHow to Win the Heart of CSS Boys
How to Win the Heart of CSS Boys
 
JS for Rails developers
JS for Rails developersJS for Rails developers
JS for Rails developers
 
Form Script
Form ScriptForm Script
Form Script
 
スマホウェブの本命 jQueryMobile
スマホウェブの本命 jQueryMobileスマホウェブの本命 jQueryMobile
スマホウェブの本命 jQueryMobile
 
Concevoir un thème pour Wordpress
Concevoir un thème pour WordpressConcevoir un thème pour Wordpress
Concevoir un thème pour Wordpress
 
美团业务系统通用Ui方案
美团业务系统通用Ui方案美团业务系统通用Ui方案
美团业务系统通用Ui方案
 
Un juego creado en php
Un juego creado en phpUn juego creado en php
Un juego creado en php
 
Facebook app API Vs2.0
Facebook app API Vs2.0Facebook app API Vs2.0
Facebook app API Vs2.0
 
Основы CSS препроцессоров и их использование в WordPress
Основы CSS препроцессоров и их использование в WordPressОсновы CSS препроцессоров и их использование в WordPress
Основы CSS препроцессоров и их использование в WordPress
 
Drupal Cms Prezentace
Drupal Cms PrezentaceDrupal Cms Prezentace
Drupal Cms Prezentace
 
Základy jQuery
Základy jQueryZáklady jQuery
Základy jQuery
 
Miniray.php
Miniray.phpMiniray.php
Miniray.php
 
Javascript and jQuery for Mobile
Javascript and jQuery for MobileJavascript and jQuery for Mobile
Javascript and jQuery for Mobile
 
JavascriptMVC
JavascriptMVCJavascriptMVC
JavascriptMVC
 

More from SkillsAndMore

La vera ottimizzazione SEO di una pagina WordPress
La vera ottimizzazione SEO di una pagina WordPressLa vera ottimizzazione SEO di una pagina WordPress
La vera ottimizzazione SEO di una pagina WordPressSkillsAndMore
 
Sfrutta il Content Marketing per attirare più clienti
Sfrutta il Content Marketing per attirare più clientiSfrutta il Content Marketing per attirare più clienti
Sfrutta il Content Marketing per attirare più clientiSkillsAndMore
 
Modifichiamo le SVG con i CSS
Modifichiamo le SVG con i CSSModifichiamo le SVG con i CSS
Modifichiamo le SVG con i CSSSkillsAndMore
 
I migliori plugin per trasformare WordPress e sfruttare l’Inbound Marketing
I migliori plugin per trasformare WordPress e sfruttare l’Inbound MarketingI migliori plugin per trasformare WordPress e sfruttare l’Inbound Marketing
I migliori plugin per trasformare WordPress e sfruttare l’Inbound MarketingSkillsAndMore
 
Come si promuove uno sviluppatore web
Come si promuove uno sviluppatore webCome si promuove uno sviluppatore web
Come si promuove uno sviluppatore webSkillsAndMore
 
Crea il tuo primo repository su GitHub
Crea il tuo primo repository su GitHubCrea il tuo primo repository su GitHub
Crea il tuo primo repository su GitHubSkillsAndMore
 
La Semantica del Web con HTML5 e Schema.org
La Semantica del Web con HTML5 e Schema.orgLa Semantica del Web con HTML5 e Schema.org
La Semantica del Web con HTML5 e Schema.orgSkillsAndMore
 
Il futuro dei CSS è nel tuo browser
Il futuro dei CSS è nel tuo browserIl futuro dei CSS è nel tuo browser
Il futuro dei CSS è nel tuo browserSkillsAndMore
 
Aggiungiamo Stile al Progetto con i CSS3
Aggiungiamo Stile al Progetto con i CSS3Aggiungiamo Stile al Progetto con i CSS3
Aggiungiamo Stile al Progetto con i CSS3SkillsAndMore
 
Lezione 3 del corso Web Design from Ground to Top
Lezione 3 del corso Web Design from Ground to TopLezione 3 del corso Web Design from Ground to Top
Lezione 3 del corso Web Design from Ground to TopSkillsAndMore
 
Lezione 2 del corso Web Design from Ground to Top
Lezione 2 del corso Web Design from Ground to TopLezione 2 del corso Web Design from Ground to Top
Lezione 2 del corso Web Design from Ground to TopSkillsAndMore
 
Lezione 1 del corso Web Design from Ground to Top
Lezione 1 del corso Web Design from Ground to TopLezione 1 del corso Web Design from Ground to Top
Lezione 1 del corso Web Design from Ground to TopSkillsAndMore
 
Scopri le Fondamenta del Web Design
Scopri le Fondamenta del Web DesignScopri le Fondamenta del Web Design
Scopri le Fondamenta del Web DesignSkillsAndMore
 
Conosci SASS e Migliora i tuoi CSS
Conosci SASS e Migliora i tuoi CSSConosci SASS e Migliora i tuoi CSS
Conosci SASS e Migliora i tuoi CSSSkillsAndMore
 
HTML5 Forms: Cosa possiamo fare Oggi
HTML5 Forms: Cosa possiamo fare OggiHTML5 Forms: Cosa possiamo fare Oggi
HTML5 Forms: Cosa possiamo fare OggiSkillsAndMore
 
Costruiamo i backlinks
Costruiamo i backlinksCostruiamo i backlinks
Costruiamo i backlinksSkillsAndMore
 

More from SkillsAndMore (16)

La vera ottimizzazione SEO di una pagina WordPress
La vera ottimizzazione SEO di una pagina WordPressLa vera ottimizzazione SEO di una pagina WordPress
La vera ottimizzazione SEO di una pagina WordPress
 
Sfrutta il Content Marketing per attirare più clienti
Sfrutta il Content Marketing per attirare più clientiSfrutta il Content Marketing per attirare più clienti
Sfrutta il Content Marketing per attirare più clienti
 
Modifichiamo le SVG con i CSS
Modifichiamo le SVG con i CSSModifichiamo le SVG con i CSS
Modifichiamo le SVG con i CSS
 
I migliori plugin per trasformare WordPress e sfruttare l’Inbound Marketing
I migliori plugin per trasformare WordPress e sfruttare l’Inbound MarketingI migliori plugin per trasformare WordPress e sfruttare l’Inbound Marketing
I migliori plugin per trasformare WordPress e sfruttare l’Inbound Marketing
 
Come si promuove uno sviluppatore web
Come si promuove uno sviluppatore webCome si promuove uno sviluppatore web
Come si promuove uno sviluppatore web
 
Crea il tuo primo repository su GitHub
Crea il tuo primo repository su GitHubCrea il tuo primo repository su GitHub
Crea il tuo primo repository su GitHub
 
La Semantica del Web con HTML5 e Schema.org
La Semantica del Web con HTML5 e Schema.orgLa Semantica del Web con HTML5 e Schema.org
La Semantica del Web con HTML5 e Schema.org
 
Il futuro dei CSS è nel tuo browser
Il futuro dei CSS è nel tuo browserIl futuro dei CSS è nel tuo browser
Il futuro dei CSS è nel tuo browser
 
Aggiungiamo Stile al Progetto con i CSS3
Aggiungiamo Stile al Progetto con i CSS3Aggiungiamo Stile al Progetto con i CSS3
Aggiungiamo Stile al Progetto con i CSS3
 
Lezione 3 del corso Web Design from Ground to Top
Lezione 3 del corso Web Design from Ground to TopLezione 3 del corso Web Design from Ground to Top
Lezione 3 del corso Web Design from Ground to Top
 
Lezione 2 del corso Web Design from Ground to Top
Lezione 2 del corso Web Design from Ground to TopLezione 2 del corso Web Design from Ground to Top
Lezione 2 del corso Web Design from Ground to Top
 
Lezione 1 del corso Web Design from Ground to Top
Lezione 1 del corso Web Design from Ground to TopLezione 1 del corso Web Design from Ground to Top
Lezione 1 del corso Web Design from Ground to Top
 
Scopri le Fondamenta del Web Design
Scopri le Fondamenta del Web DesignScopri le Fondamenta del Web Design
Scopri le Fondamenta del Web Design
 
Conosci SASS e Migliora i tuoi CSS
Conosci SASS e Migliora i tuoi CSSConosci SASS e Migliora i tuoi CSS
Conosci SASS e Migliora i tuoi CSS
 
HTML5 Forms: Cosa possiamo fare Oggi
HTML5 Forms: Cosa possiamo fare OggiHTML5 Forms: Cosa possiamo fare Oggi
HTML5 Forms: Cosa possiamo fare Oggi
 
Costruiamo i backlinks
Costruiamo i backlinksCostruiamo i backlinks
Costruiamo i backlinks
 

Crea un tema compatibile con le ultime novità WordPress