(→Creating Pages) |
(→Template/modelli di pagina) |
||
(51 intermediate revisions by 7 users not shown) | |||
Line 2: | Line 2: | ||
{{en|Pages}} |
{{en|Pages}} |
||
{{es|Pages}} |
{{es|Pages}} |
||
+ | {{fr|Pages}} |
||
{{it|Pagine}} |
{{it|Pagine}} |
||
{{ja|Pages}} |
{{ja|Pages}} |
||
{{ko|Pages}} |
{{ko|Pages}} |
||
+ | {{lo|Pages}} |
||
+ | {{mya|Pages}} |
||
+ | {{nl|Pagina's}} |
||
⚫ | |||
⚫ | |||
{{sk|Stránky}} |
{{sk|Stránky}} |
||
{{th|Pages}} |
{{th|Pages}} |
||
{{zh-cn|页面}} |
{{zh-cn|页面}} |
||
{{zh-tw|網誌分頁}} |
{{zh-tw|網誌分頁}} |
||
⚫ | |||
⚫ | |||
}} |
}} |
||
+ | __TOC__In WordPress, potete creare articoli (posts) o pagine (pages). Quando state creando dei contenuti nel blog, state scrivendo un articolo. Gli articoli appaiono automaticamente in ordine cronologicamente inverso nella home page del vostro blog. Le pagine servono a contenuti come «A proposito di…», «Contatti», ecc. Le pagine vivono al di fuori della normale cronologia del blog, e sono spesso utilizzate per presentare informazioni estemporanee su voi stessi o sul vostro sito – informazioni che sono sempre valide. Potete utilizzare le pagine per organizzare e gestire qualsiasi contenuto. |
||
− | __TOC__In WordPress, you can write either posts or Pages. When you're writing a regular blog entry, you write a post. Posts automatically appear in reverse chronological order on your blog's home page. Pages are for content such as "About," "Contact," etc. Pages live outside of the normal blog chronology, and are often used to present timeless information about yourself or your site -- information that is always applicable. You can use Pages to organize and manage any content. |
||
+ | Oltre alla classiche pagine fondamentali «A proposito di...» e «Contatti», altri esempi di pagine comuni includono copyright, notifiche, informazioni legali, permessi di riutilizzo, informazioni aziendali, e istruzioni di accessibilità. |
||
− | In addition to the generally required "About" and "Contact" Pages, other examples of common pages include Copyright, Disclosure, Legal Information, Reprint Permissions, Company Information, and Accessibility Statement. |
||
+ | In generale, le pagine sono molto simili agli articoli, nel senso che entrambi hanno un titolo e un contenuto e possono utilizzare i file template del vostro tema WordPress per conservare un aspetto consistente su tutto il vostro sito. Le pagine, tuttavia, possiedono alcune situazioni chiave che le rendono abbastanza diverse dagli articoli. |
||
− | In general, Pages are very similar to Posts in that they both have Titles and Content and can use your WordPress Theme templates files to maintain a consistent look throughout your site. Pages, though, have several key distinctions that make them quite different from Posts. |
||
− | ''' |
+ | '''Cosa sono le pagine:'''<br /> |
+ | * Le pagine sono per del contenuto che è meno dipendente al tempo rispetto ai post/articoli. |
||
− | * Pages are for content that is less time-dependent than Posts. |
||
+ | * Le pagine possono essere organizzate in pagine e [[#Organizzare_le_vostre_pagine|sotto-pagine]]. |
||
− | * Pages can be organized into pages and [[#Organizing_Your_Pages|SubPages]]. |
||
− | * |
+ | * Le pagine possono utilizzare diversi [[#Page Templates|template di pagina]] che possono includere [[Stepping Into Templates|file di template]], [[it:Tag_dei_template|tag dei template]] e altro codice PHP. |
+ | * Le pagine possono avere una più complessa gamma di aggiustamenti visivi prontamente disponibili, al posto di utilizzare temi sofisticati con ampie possibilità di personalizzazione. |
||
− | * Pages may have a more complex array of readily available display adjustments when using sophisticated Themes with extensive customization. |
||
− | * In |
+ | * In sostanza, le pagine sono per i contenuti non-blog. È possibile rimuovere tutti, o la maggior parte degli articoli da una installazione di WordPress, e, quindi, creare un sito web standard (non-blog). |
− | ''' |
+ | '''Cosa NON sono le pagine:'''<br /> |
+ | * Le pagine non sono articoli, e neppure sono tratte da grandi opere di narrativa. Esse non circolano attraverso la pagina principale del vostro blog. Sono disponibili i plugin WordPress per modificare il predefinito se necessario. |
||
− | * Pages are not Posts, nor are they excerpted from larger works of fiction. They do not cycle through your blog's main page. WordPress Plugins are available to change the default if necessary. |
||
+ | * Le pagine non possono essere associate alle categorie e no si può assegnare ad esse i tag. La struttura organizzativa per le pagine dipende solo dalla loro interrelazione gerarchica, e non dai tag o dalle categorie. |
||
− | * Pages cannot be associated with Categories and cannot be assigned Tags. The organizational structure for Pages comes only from their hierarchical interrelationships, and not from Tags or Categories. |
||
− | * |
+ | * Le pagine non sono file. Sono memorizzate nel tuo database proprio come succede agli articoli. |
− | * |
+ | * Anche se potrete inserire tag dei template e codice PHP all’interno di un template di pagina, non potrete mettere tutto ciò direttamente in un contenuto di pagina o articolo senza l’utilizzo di un plugin WordPress come [http://wordpress.org/extend/plugins/exec-php/ Exec-PHP] che sovrascrive il codice che filtra il processo. |
+ | * Le pagine non sono incluse nel feed del tuo sito. |
||
− | * Pages are not included in your site's feed. |
||
+ | * Pagine e articoli possono attirare l’attenzione in modi diversi sia da esseri umani che dai motori di ricerca. |
||
− | * Pages and Posts may attract attention in different ways from humans or search engines. |
||
− | * |
+ | * Una pagina (o un articolo specifico), se lo si desidera, può essere impostata come [[Creating_a_Static_Front_Page|prima pagina statica]] e con una pagina separata fissata per gli ultimi articoli del blog, in genere chiamata «Blog». |
− | ==Creare le |
+ | ==Creare le pagine== |
− | [[Image: |
+ | [[Image:Pagine-Aggiungi-nuova-4.3.png|right|thumbnail|Pagine > Aggiungi nuova]]Per creare una nuova pagina, eseguite il login nella vostra installazione di WordPress con sufficienti privilegi da amministratore per la creazione di nuovi articoli. Selezionate l’opzione [[Administration_Panels#Add_New_Page|Pagine]] > [[Pages_Add_New_SubPanel|Aggiungi nuova]] per iniziare a comporre una nuova Pagina. |
+ | ===Organizza le tue pagine=== |
||
+ | Come esistono sottocategorie all'interno di una categoria, posso esserci «sottopagine» all'interno delle tue pagine in WordPress, creando quindi una gerarchia di pagine. |
||
− | ===Organizing Your Pages=== |
||
+ | Per esempio, un sito WordPress per un’agenzia di viaggio potrebbe avere una pagina per ogni continente e nazione in cui l’agenzia organizza viaggi. All’interno della pagina denominata «Africa» potremmo avere delle sottopagine per Lesotho, Cameroon, Togo, e Swaziland. Un’altra pagina potrebbe essere «Sud America” con le sottopagine relative al Brasile, Argentina e Cile. Il sito sarebbe quindi così: |
||
− | Just as you can have subcategories within your Categories, you can also have '''SubPages''' within your Pages, creating a hierarchy of pages. |
||
− | For example, a WordPress site for a travel agent may feature an individual Page for each continent and country to which the agency can make travel arrangements. Under the Page titled "Africa" would be SubPages for Lesotho, Cameroon, Togo, and Swaziland. Another parent Page "South America" would feature SubPages of Brazil, Argentina, and Chile. Your site would list: |
||
*Africa |
*Africa |
||
**Cameroon |
**Cameroon |
||
Line 50: | Line 54: | ||
**Swaziland |
**Swaziland |
||
**Togo |
**Togo |
||
− | * |
+ | *Sud America |
**Argentina |
**Argentina |
||
**Brazil |
**Brazil |
||
− | ** |
+ | **Cile |
+ | |||
+ | Per creare sottopagine: |
||
⚫ | |||
− | To create subPages: |
||
+ | # Nel menu a destra, clicca nel menu a tendina «Pagina genitore». Il menu a tendina contiene una lista di pagine che sono già state create sul tuo sito. |
||
⚫ | |||
+ | # Seleziona la pagina genitore appropriata dal menu a tendina per rendere la pagina attuale una sua pagina child. |
||
− | # In the right menu, click the "Page Parent" drop-down menu. The drop-down menu contains a list of all the Pages already created for your site. |
||
+ | # Aggiungi del testo/contenuto nella sottopagina. |
||
− | # Select the appropriate parent Page from the drop-down menu to make the current Page a child Page. |
||
+ | # Clicca su «Pubblica» quando è tutto pronto per la pubblicazione. |
||
− | # Add content to the subPage. |
||
− | # Click Publish when ready. |
||
− | + | Quando le tue pagine sono [[#Listing Your Pages on Your Site|ordinate]], la pagina child viene inserita come sotto pagina della pagina genitore. Anche i [[Using Permalinks|Permalink]] delle tue pagine riflettono questa struttura delle pagine. |
|
− | + | Nell’esempio di qui sotto, il [[Using Permalinks|Permalink]] per la pagina Cameroon sarà: |
|
<nowiki>http://example.com/africa/cameroon/</nowiki> |
<nowiki>http://example.com/africa/cameroon/</nowiki> |
||
− | === |
+ | ===Modificare URL delle pagine=== |
+ | Per cambiare URL o «slug» di una pagina, utilizzare l’opzione '''Modifica''' sotto il titolo della pagina sulla schermata di modifica. |
||
− | To change the URL or "slug" of a Page, use the '''Edit Slug''' feature under the Page title on the '''WordPress Administration > Page''' edit screen. |
||
− | === |
+ | ===Creare una lista di pagine=== |
− | WordPress |
+ | WordPress può «automaticamente» generare una lista di pagine sul tuo sito all’interno di una barra laterale o a piè di pagina, per esempio, usando [[it:Tag_dei_template| tag dei template]] chiamato <tt>wp_list_pages()</tt>. Vedi anche la pagina dei [[Template Tags/wp_list_pages|wp_list_pages]] per avere più informazioni su come personalizzare il modo in cui WordPress mostra la lista delle pagine sul tuo sito. |
− | + | Puoi anche collegare le tue pagine manualmente con un link HTML. Per esempio, se vuoi che la tua pagina copyright sia presente sul tuo footer a piè di pagina, puoi metterlo attraverso un link HTML come vedi sotto: <br /> |
|
− | <nowiki><a title= |
+ | <nowiki><a title=“Informazioni Copyright" href="http://example/com/copyright/">Copyright 1996-2012</a></nowiki> |
+ | Ci sono anche dei plugin che ti aiutano a mostrare la lista delle pagina negli articoli o in altre aree del tuo tema WordPress. |
||
− | There are also WordPress Plugins that will help you display a list of Pages within in Posts and in other areas of your WordPress Theme. |
||
+ | ==Template/modelli di pagina== |
||
− | ==Page Templates== |
||
− | + | Singole pagine possono essere impostate per utilizzare uno specifico e personalizzato '''Page Template''' (un file PHP di template/modello di tema WordPress, ad es. snarfer.php) che potete creare all’interno del vostro tema. Vedi come [[#Creare un template di pagina personalizzato|Creare un template di pagina personalizzato]] più giù, su come creare un file di modello personalizzato per una pagina. Questo nuovo template/modello di pagina sovrascriverà quello del template di pagina predefinito <tt>page.php</tt> incluso nel tuo tema. |
|
+ | WordPress può essere configurato per utilizzare vari template per diverse pagine. Per selezionare un template differente: |
||
− | WordPress can be configured to use different Page Templates for different Pages. To select a different Page Template: |
||
+ | # Dal menu di destra, seleziona la voce dalla lista a discesa '''Modello'''. |
||
− | # On the right menu, select the drop-down menu labeled "Page Template." |
||
+ | # Scegli il file template di tema WordPress che deve essere utilizzato quando verrà visualizzata questa particolare pagina. |
||
− | # Choose the WordPress Theme template file to be used when displaying this particular Page. |
||
− | ''' |
+ | '''Cosa devi sapere sui template/modelli di pagina:''' |
+ | # Per accedere al selettore dei template di pagina, ci deve essere almeno un template di pagina custom disponibile nel tema attivo (si veda [[#Creare un template di pagina personalizzato|Creare un template di pagina personalizzato]] per imparare a crearne uno). Se esiste una pagina custom ma non si riesce ancora a visualizzare il selettore di template di pagina, riattivate il tema corrente. |
||
− | # In order to access the Page Template selector, there must be at least one custom Page Template available in the active theme (see [[#Creating Your Own Page Templates|Creating your own Page Templates]] below to learn how to create one). If a custom page exists, but you still are not able to see Page Template selector, re-activate your current theme. |
||
− | # |
+ | # Per capire bene come WordPress utilizza automaticamente specifici template di pagina in un tema, si veda la [[Template Hierarchy]]. |
− | # |
+ | # Se si cambia tema di WordPress, questi template di pagina non saranno più disponibili. Il design ed il layout di pagina torneranno alla visualizzazione di default per il tema di WordPress attuale. |
+ | ===Template di pagina del tema di default=== |
||
− | ===Default Theme Page Templates=== |
||
− | + | TwentyEleven, il tema di default di WordPress, contiene tre template di pagina da usare: |
|
− | * <tt>page.php</tt> - |
+ | * <tt>page.php</tt> - Template di pagina di default: visualizza il contenuto della pagina |
− | * <tt>archives.php</tt> - |
+ | * <tt>archives.php</tt> - ignora il contenuto di pagina e, invece, visualizza una lista di archivi per mese e archivi per soggetto (per categoria) |
− | * <tt>links.php</tt> - |
+ | * <tt>links.php</tt> - ignora il contenuto di pagina e, invece, visualizza i tuoi link usando [[Template_Tags/wp_list_bookmarks | wp_list_bookmarks()]] |
+ | ===Che template è utilizzato per visualizzare una pagina particolare?=== |
||
− | ===What Template is Used to Display a Particular Page?=== |
||
− | WordPress |
+ | WordPress cerca i diversi template di pagina nel tema attivo di WordPress basandosi su [[Template Hierarchy]]. Il primo che trova verrà utilizzato per visualizzare una pagina. WordPress cercherà i file nel seguente ordine: |
+ | #Il 'template di pagina' per la pagina selezionata |
||
− | #The Page's selected "Page Template" |
||
#<tt>page.php</tt> |
#<tt>page.php</tt> |
||
#<tt>index.php</tt> |
#<tt>index.php</tt> |
||
− | + | La [[Template Hierarchy]] di WordPress riconosce anche pagine o post specifici automaticamente senza bisogno di assegnarli ad uno specifico template di pagina. Se l'ID o lo slug di pagina sono presenti nel nome del template di pagina, verrà usato il corretto template di pagina. |
|
* page-{id}.php |
* page-{id}.php |
||
* page-{slug}.php |
* page-{slug}.php |
||
− | + | Se l'ID di pagina è 42, sarà automaticamente usato il template <tt>page-42.php</tt>. Se lo slug di pagina è 'About', sarà automaticamente usato il template <tt>page-about.php</tt>. |
|
+ | ==Creare un template di pagina personalizzato== |
||
− | ==Creating Your Own Page Templates== |
||
− | + | I file che definiscono ognuno dei Modelli di Pagina si trovano nella vostra cartella [[Using Themes|Temi]] sotto <tt>/wp-content</tt>. Per creare una nuovo Modello Personalizzato di Pagina per una Pagina dovrete creare un file utilizzato un editor di Puro Testo (ad es. Notepad o TextWrangler). Chiamate il vostro primo Modello di Pagina <tt>snarfer.php</tt>. |
|
− | + | In cima al file <tt>snarfer.php</tt>, inserite ciò che segue: |
|
<?php |
<?php |
||
Line 128: | Line 133: | ||
?> |
?> |
||
− | + | Il codice qui sopra è richiesto e definisce il file <tt>snarfer.php</tt> come il Modello "Snarfer". "Snarfer" può essere sostituito con qualsiasi testo per modificare il nome del Modello di Pagina. Il Nome del Modello apparirà nel WordPress Theme Editor per la modifica. Per ulteriori informazioni sulle convenzioni di nomina del Tema vedetevi [[Theme Development#Template Files List|nome file riservati per i Temi]] per i nomi di file che ''non'' dovreste utilizzare. |
|
− | + | Quello che segue le prime cinque linee di codice dipende da voi. Il codice che scrivete controllerà appariranno le Pagine che utilizzano il Modello di Pagina Snarfer. See [[Template Tags]] for a description of the various WordPress Template functions you can use for this purpose. You may find it more convenient to copy the dynamic content generating code from another Template file (perhaps <tt>page.php</tt> or <tt>index.php</tt>) to <tt>snarfer.php</tt>. This will save time and allow you to only alter the HTML and PHP code instead of creating it all from scratch. |
|
Once you have created and saved the file, upload it to your theme's folder inside wp-content/themes using [[FTP_Clients|FTP]] or whatever file management application your host provides. |
Once you have created and saved the file, upload it to your theme's folder inside wp-content/themes using [[FTP_Clients|FTP]] or whatever file management application your host provides. |
||
Line 333: | Line 338: | ||
</pre> |
</pre> |
||
− | == |
+ | == La natura dinamica delle pagine WordPress == |
A web page can be ''static'' or ''dynamic.'' Static pages, such as a regular HTML page that you might create with Dreamweaver, are those which have been created once and do not have to be regenerated every time a person visits the page. In contrast, dynamic pages, such as those you create with WordPress, do need to be regenerated every time they are viewed; code for what to generate on the page has been specified by the author, but not the actual page itself. These use extensive PHP code which is evaluated each time the page is visited, and the content is thus generated upon each new visit. |
A web page can be ''static'' or ''dynamic.'' Static pages, such as a regular HTML page that you might create with Dreamweaver, are those which have been created once and do not have to be regenerated every time a person visits the page. In contrast, dynamic pages, such as those you create with WordPress, do need to be regenerated every time they are viewed; code for what to generate on the page has been specified by the author, but not the actual page itself. These use extensive PHP code which is evaluated each time the page is visited, and the content is thus generated upon each new visit. |
Languages: English • Español • Français • Italiano • 日本語 한국어 • ລາວ • myanmar • Nederlands • Português do Brasil • Русский • Slovenčina • ไทย • 中文(简体) • 中文(繁體) • (Add your language)
Oltre alla classiche pagine fondamentali «A proposito di...» e «Contatti», altri esempi di pagine comuni includono copyright, notifiche, informazioni legali, permessi di riutilizzo, informazioni aziendali, e istruzioni di accessibilità.
In generale, le pagine sono molto simili agli articoli, nel senso che entrambi hanno un titolo e un contenuto e possono utilizzare i file template del vostro tema WordPress per conservare un aspetto consistente su tutto il vostro sito. Le pagine, tuttavia, possiedono alcune situazioni chiave che le rendono abbastanza diverse dagli articoli.
Cosa sono le pagine:
Cosa NON sono le pagine:
Come esistono sottocategorie all'interno di una categoria, posso esserci «sottopagine» all'interno delle tue pagine in WordPress, creando quindi una gerarchia di pagine.
Per esempio, un sito WordPress per un’agenzia di viaggio potrebbe avere una pagina per ogni continente e nazione in cui l’agenzia organizza viaggi. All’interno della pagina denominata «Africa» potremmo avere delle sottopagine per Lesotho, Cameroon, Togo, e Swaziland. Un’altra pagina potrebbe essere «Sud America” con le sottopagine relative al Brasile, Argentina e Cile. Il sito sarebbe quindi così:
Per creare sottopagine:
Quando le tue pagine sono ordinate, la pagina child viene inserita come sotto pagina della pagina genitore. Anche i Permalink delle tue pagine riflettono questa struttura delle pagine.
Nell’esempio di qui sotto, il Permalink per la pagina Cameroon sarà:
http://example.com/africa/cameroon/
Per cambiare URL o «slug» di una pagina, utilizzare l’opzione Modifica sotto il titolo della pagina sulla schermata di modifica.
WordPress può «automaticamente» generare una lista di pagine sul tuo sito all’interno di una barra laterale o a piè di pagina, per esempio, usando tag dei template chiamato wp_list_pages(). Vedi anche la pagina dei wp_list_pages per avere più informazioni su come personalizzare il modo in cui WordPress mostra la lista delle pagine sul tuo sito.
Puoi anche collegare le tue pagine manualmente con un link HTML. Per esempio, se vuoi che la tua pagina copyright sia presente sul tuo footer a piè di pagina, puoi metterlo attraverso un link HTML come vedi sotto:
<a title=“Informazioni Copyright" href="http://example/com/copyright/">Copyright 1996-2012</a>
Ci sono anche dei plugin che ti aiutano a mostrare la lista delle pagina negli articoli o in altre aree del tuo tema WordPress.
Singole pagine possono essere impostate per utilizzare uno specifico e personalizzato Page Template (un file PHP di template/modello di tema WordPress, ad es. snarfer.php) che potete creare all’interno del vostro tema. Vedi come Creare un template di pagina personalizzato più giù, su come creare un file di modello personalizzato per una pagina. Questo nuovo template/modello di pagina sovrascriverà quello del template di pagina predefinito page.php incluso nel tuo tema.
WordPress può essere configurato per utilizzare vari template per diverse pagine. Per selezionare un template differente:
Cosa devi sapere sui template/modelli di pagina:
TwentyEleven, il tema di default di WordPress, contiene tre template di pagina da usare:
WordPress cerca i diversi template di pagina nel tema attivo di WordPress basandosi su Template Hierarchy. Il primo che trova verrà utilizzato per visualizzare una pagina. WordPress cercherà i file nel seguente ordine:
La Template Hierarchy di WordPress riconosce anche pagine o post specifici automaticamente senza bisogno di assegnarli ad uno specifico template di pagina. Se l'ID o lo slug di pagina sono presenti nel nome del template di pagina, verrà usato il corretto template di pagina.
Se l'ID di pagina è 42, sarà automaticamente usato il template page-42.php. Se lo slug di pagina è 'About', sarà automaticamente usato il template page-about.php.
I file che definiscono ognuno dei Modelli di Pagina si trovano nella vostra cartella Temi sotto /wp-content. Per creare una nuovo Modello Personalizzato di Pagina per una Pagina dovrete creare un file utilizzato un editor di Puro Testo (ad es. Notepad o TextWrangler). Chiamate il vostro primo Modello di Pagina snarfer.php.
In cima al file snarfer.php, inserite ciò che segue:
<?php /* Template Name: Snarfer */ ?>
Il codice qui sopra è richiesto e definisce il file snarfer.php come il Modello "Snarfer". "Snarfer" può essere sostituito con qualsiasi testo per modificare il nome del Modello di Pagina. Il Nome del Modello apparirà nel WordPress Theme Editor per la modifica. Per ulteriori informazioni sulle convenzioni di nomina del Tema vedetevi nome file riservati per i Temi per i nomi di file che non dovreste utilizzare.
Quello che segue le prime cinque linee di codice dipende da voi. Il codice che scrivete controllerà appariranno le Pagine che utilizzano il Modello di Pagina Snarfer. See Template Tags for a description of the various WordPress Template functions you can use for this purpose. You may find it more convenient to copy the dynamic content generating code from another Template file (perhaps page.php or index.php) to snarfer.php. This will save time and allow you to only alter the HTML and PHP code instead of creating it all from scratch.
Once you have created and saved the file, upload it to your theme's folder inside wp-content/themes using FTP or whatever file management application your host provides.
The following is a list of instructional examples of custom Page Template files. Please note that your WordPress Theme's template file structure and architecture may be different.
Example of a Page Template that shows the Page's content at the top, and then displays a list of archive months and categories below it.
Save this to arc-cont.php:
<?php /* Template Name: Archives with Content */ ?> <?php get_header(); ?> <div id="content" class="widecolumn"> <?php if (have_posts()) : while (have_posts()) : the_post();?> <div class="post"> <h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2> <div class="entrytext"> <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?> </div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> </div> <div id="main"> <?php include (TEMPLATEPATH . '/searchform.php'); ?> <h2>Archives by Month:</h2> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> <h2>Archives by Subject:</h2> <ul> <?php wp_list_categories(); ?> </ul> </div> <?php get_footer(); ?>
The following custom Page Template file displays the content of the page followed by the posts from two specific categories (specified by their category slugs). It is designed to work within a child Theme of the Twenty Eleven theme. If you are using another theme, you need to replicate the HTML structure of your own theme within the template.
Save this to pageofposts.php and then assign the Page of Posts Template to your new Page:
<?php /* Template Name: Page Of Posts */ /* if you are not using this in a child of Twenty Eleven, * you need to replicate the html structure of your own theme. */ get_header(); get_sidebar(); ?> <div id="primary"> <div id="content" role="main"> <?php /* the_post will retrieve the content of the new page you * create to list the posts, e.g. as an intro to describe * which posts are shown. */ the_post(); // Display content of page get_template_part( 'content', get_post_format() ); wp_reset_postdata(); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( // Change these category SLUGS to suit your use. 'category_name' => 'antiquarianism, championship', 'paged' => $paged ); $list_of_posts = new WP_Query( $args ); twentyeleven_content_nav( 'nav-above' ); while ( $list_of_posts->have_posts() ): $list_of_posts->the_post(); // Display content of posts get_template_part( 'content', get_post_format() ); endwhile; twentyeleven_content_nav( 'nav-below' ); ?> </div><!-- /#content --> </div><!-- /#primary --> <?php get_footer();
This example features a Page Template that displays posts from a specific category depending on a Custom Field assigned to a Page. The value of the Custom Field "category" is retrieved and used as the category to retrieve the posts in that category. If the category of posts you want to display is called "Events" then assign the Custom Field "category" with a value of "Events" to the Page. Note that this will adhere to pagination rules meaning that four (4) posts will display per page with links to older/newer posts provided.
Save this to pageofposts.php and then assign the Page of Posts Template when creating the action Page:
<?php /* Template Name: Page Of Posts with Custom Fields */ get_header(); ?> <div id="content" class="narrowcolumn"> <?php if (is_page() ) { $category = get_post_meta($posts[0]->ID, 'category', true); } if ($category) { $cat = get_cat_ID($category); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $post_per_page = 4; // -1 shows all posts $do_not_show_stickies = 1; // 0 to show stickies $args=array( 'category__in' => array($cat), 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged, 'posts_per_page' => $post_per_page, 'ignore_sticky_posts' => $do_not_show_stickies ); $temp = $wp_query; // assign orginal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); if( have_posts() ) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small> <div class="entry"> <?php the_content('Read the rest of this entry »'); ?> </div> <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; $wp_query = $temp; //reset back to original query } // if ($category) ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>
Custom Post Types allow WordPress sites to display many different types of content. This example displaying the posts on a Page belonging to a custom post type. In this case, the custom post type is book. The custom Page Template below can work in any Theme or as a Child Theme template file.
<?php /** * Template Name: Page of Books * * Selectable from a dropdown menu on the edit page screen. */ ?> <?php get_header(); ?> <div id="container"> <div id="content"> <?php $type = 'book'; $args=array( 'post_type' => $type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => 2, 'ignore_sticky_posts'=> 1 ); $temp = $wp_query; // assign ordinal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); ?> <?php get_template_part( 'loop', 'index' );?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?>
A web page can be static or dynamic. Static pages, such as a regular HTML page that you might create with Dreamweaver, are those which have been created once and do not have to be regenerated every time a person visits the page. In contrast, dynamic pages, such as those you create with WordPress, do need to be regenerated every time they are viewed; code for what to generate on the page has been specified by the author, but not the actual page itself. These use extensive PHP code which is evaluated each time the page is visited, and the content is thus generated upon each new visit.
Almost everything in WordPress is generated dynamically, including Pages. Everything published in WordPress (Posts, Pages, Comments, Blogrolls, Categories, etc...) is stored in the MySQL database. When the site is accessed, the database information is used by your WordPress Templates from your current Theme to generate the web page being requested.
An example of a static page might be an HTML document (without any PHP code). The problem with purely static pages is that they are difficult to maintain. Changes you make to your WordPress settings, Themes and Templates will not be propagated to pages coded only in HTML. The Page feature of WordPress was developed to alleviate this problem. By using Pages, you no longer have to update your static pages every time you change the style of your site. If written properly, your dynamic Pages will update along with the rest of your blog.
Despite the dynamic nature of Pages, many people refer to them as being static. They are actually called "pseudo-static" web pages. In other words, a Page contains static information but is generated dynamically. Thus, either "static," "dynamic," or "pseudo-static" may be validly used to describe the nature of the WordPress Page feature.