Aggiunta di intestazioni predefinite aggiuntive al tema WordPress Twenty Ten

Aggiunta di intestazioni predefinite aggiuntive al tema WordPress Twenty Ten / Temi

Il tema Twenty Ten viene fornito con otto intestazioni predefinite. Qualsiasi intestazione predefinita impostata viene sostituita con "immagine in primo piano" di un post. Puoi vedere la nuova intestazione solo quando visualizzi quel post. Nel suggerimento rapido di WordPress di questa settimana vedremo quanto è semplice aggiungere ulteriori intestazioni al pannello dell'intestazione.

Guarda lo Screencast

functions.php

Apri il file functions.php del tema Twenty Ten. Individua la seguente sezione:

// Intestazioni personalizzate predefinite confezionate con il tema. % s è un segnaposto per l'URI della directory del modello di temi.

Quello che segue è un array che elenca le intestazioni predefinite correnti e la loro posizione. Per aggiungere il tuo, aggiungi una virgola dopo l'ultima parentesi della matrice dell'intestazione del tramonto. Ecco un esempio di come può essere dopo aver aggiunto altre due intestazioni:

 register_default_headers (array ('berries' => array ('url' => '% s / images / headers / berries.jpg', 'thumbnail_url' => '% s / images / headers / berries-thumbnail.jpg', / * traduttori: intestazione descrizione dell'immagine * / 'descrizione' => __ ('Berries', 'twentyten')), 'cherryblossom' => array ('url' => '% s / images / headers / cherryblossoms.jpg', 'thumbnail_url' => '% s / images / headers / cherryblossoms-thumbnail.jpg', / * traduttori: intestazione descrizione dell'immagine * / 'description' => __ ('Cherry Blossoms', 'twentyten')), 'concave' => array ('url' => '% s / images / headers / concave.jpg', 'thumbnail_url' => '% s / images / headers / concave-thumbnail.jpg', / * traduttori: intestazione descrizione dell'immagine * / 'description' => __ ('Concave', 'twentyten')), 'fern' => array ('url' => '% s / images / headers / fern.jpg', 'thumbnail_url' => '% s / images / headers / fern-thumbnail.jpg ', / * traduttori: intestazione descrizione dell'immagine * /' description '=> __ (' Fern ',' twentyten ')),' forestfloor '=> array (' url '= > '% s / immagini / intestazioni / forestfloor.jpg', 'thumbnail_ur l '=>'% s / immagini / intestazioni / forestfloor-thumbnail.jpg ', / * traduttori: intestazione descrizione dell'immagine * /' descrizione '=> __ (' Forest Floor ',' twentyten ')),' inkwell '= > array ('url' => '% s / images / headers / inkwell.jpg', 'thumbnail_url' => '% s / immagini / intestazioni / inkwell-thumbnail.jpg', / * traduttori: intestazione descrizione dell'immagine * / 'description' => __ ('Inkwell', 'twentyten')), 'path' => array ('url' => '% s / images / headers / path.jpg', 'thumbnail_url' => '% s /images/headers/path-thumbnail.jpg ', / * traduttori: header image description * /' description '=> __ (' Path ',' twentyten ')),' sunset '=> array (' url '=> '% s / images / headers / sunset.jpg', 'thumbnail_url' => '% s / images / headers / sunset-thumbnail.jpg', / * traduttori: header descrizione dell'immagine * / 'description' => __ (' Sunset ',' twentyten ')),' waterfall '=> array (' url '=>'% s / images / headers / waterfall.jpg ',' thumbnail_url '=>'% s / images / headers / waterfall-thumbnail .jpg ', / * traduttori: header image description * /' description '=> __ (' Waterfall ',' twent yten ')),' mountain '=> array (' url '=>'% s / images / headers / mountain.jpg ',' thumbnail_url '=>'% s / images / headers / mountain-thumbnail.jpg ', / * traduttori: header image description * / 'description' => __ ('Mountain', 'twentyten'))))); 

Consente di analizzare un po 'il codice.

register_default_headers: Questa è la funzione che crea e visualizza le intestazioni predefinite. Accetta una serie di parametri.

nome: Imposta un valore con il nome delle intestazioni. Possiamo quindi impostare una serie di valori e chiavi aggiuntivi.

url: Percorso relativo all'immagine dell'intestazione. Si noti che il percorso corrente è /images/headers/image_name.jpg

thumbnail_url: Percorso relativo a una miniatura dell'immagine dell'intestazione. Il percorso corrente è /images/headers/image_name-thumbnail.jpg

descrizione: Una descrizione dell'immagine. Questo verrà visualizzato al passaggio del mouse sopra l'immagine all'interno del Pannello Intestazioni.

Cose da notare

L'intestazione Twenty Ten è 940 × 198, qualsiasi cosa più grande di quella sarebbe stata ridimensionata; qualsiasi cosa più piccola sarebbe allungata per adattarsi a quelle dimensioni. Le immagini di anteprima possono essere impostate su qualsiasi dimensione, 230 × 48 è l'impostazione predefinita. Le immagini possono essere solo .jpg o saranno ignorate e non verranno visualizzate.