Risposte nei forum create
-
AutorePost
-
1 Settembre 2007 alle 12:53 in risposta a: Visualizzare articoli di una categoria nella sidebar #46439oruxPartecipante
Scusate il casino…
Non sono riuscito a scrivere il codice sul forum
Altro che apici rovesci?
Se mi spiegate come fare, riposto il codice in modo corretto.
Grazie
1 Settembre 2007 alle 11:48 in risposta a: Visualizzare articoli di una categoria nella sidebar #46438oruxPartecipanteGrazie uncino,
il tag che mi hai suggerito è molto interessante.
Intanto l’ho usato per sostituirlo al deprecato wp_list_cats (proprio nella sidebar).
Questo:
Code:- <h2>Categorie</h2>
-
<?php wp_list_cats(‘sort_column=name&optioncount=1&hierarchical=0’); ?>
Diventa questo:
Code:<?php wp_list_categories(‘orderby=name&title_li=<h2>Categorie</h2>’ ); ?>Purtroppo, però, il tag permette di visualizzare soltanto l’indice delle categorie senza mostrare anche gli articoli.
Ho scoperto anche una cosa insolita.
Scriviamo
Code:?php wp_list_categories(‘orderby=name&include=3’ ); ?>Se la categoria 3 è un categoria madre, senza subordinate (figlie), allora
“include” funziona correttamente.
Se la categoria 3 è una categoria figlia, oppure ha subordinate, allora
“include” non funziona e visualizza la dicitura “Senza categoria”.
Per mostrare gli articoli di una categoria ho risolto con un mini-loop:
Code:<?php if ( is_category(‘NOME_CATEGORIA’) ) { ?>- <h2>INTESTAZIONE</h2>
- <?php echo the_category(‘,’); ?>
-
<?php query_posts(‘category_name=NOME_CATEGORIA & showposts=10000 & orderby=date & order=ASC’); ?>
- ” title=”Leggi: "<?php the_title(); ?>"”><?php the_title(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?><?php endwhile; ?><?php endif; ?>
Le cose si complicano quando ci sono sottocategorie, perché non posso usare questo codice:
Code:- <?php echo the_category(‘,’); ?>
che mostra il link alla categoria che si sta visualizzando.
Lo devo sostituire con:
Code:- /?cat=ID_DELLA_CATEGORIA” title=”Visualizza tutti gli scritti archiviati in: "NOME_DELLA_CATEGORIA"”>NOME_DELLA_CATEGORIA
C’è un modo più pulito?
28 Agosto 2007 alle 22:36 in risposta a: Kubrick, template e if ( !$withcomments && !is_single() ) { #46383oruxPartecipanteHo detto qualche cavolata nel post precedente cosଠtento di correggermi.
Il “!” è una negazione cosଠil significato del codice dovrebbe essere:
Se la pagina che si visualizza non è $withcomments e non è single
allora usa come sfondo kubrickbg.jpg
altrimenti usa come sfondo kubrickbgwide.jpg
PURTROPPO NON RIESCO A RISOLVERE IN MODO PULITO
La variabile &withcomments non compare altrove (penso) e sembra inutile. Il codice può essere riscritto infatti
if ( !is_single() ) {
oppure
if ( is_single() ) {
invertendo le immagini di background.LA SOLUZIONE TAMPONE (oltre a quella di Ondapi, che forse è l’unica funzionale)
andrebbe scritta:
if ( !is_single() || !is_page(ID_PAGINE_a_cui _si_applica_il_template) ) {
oppure
if ( is_single() || is_page(ID_PAGINE_a_cui _si_applica_il_template) ) {
invertendo le immagini di background.L’ID_PAGINA è assolutamente necessario: ne serve almeno uno. Il campo non può restare vuoto, altrimenti valuterebbe tutte le pagine page che hanno la sidebar sbagliando l’immagine di sfondo.
Possibile che nessuno mi sa dare la soluzione?
Dove sono finiti i guru?
23 Agosto 2007 alle 22:49 in risposta a: Kubrick, template e if ( !$withcomments && !is_single() ) { #46306oruxPartecipanteGrazie Ondapi!
Potrebbe essere una scappatoia, però c’è il problema che in header.php ci sono anche molte informazioni meta che potrei voler aggiornare manualmente ogni tanto.
“Moltiplicare” per cosଠdire gli header mi costringerebbe ogni volta ad aggiornare più di un file e se volessi creare più di un template diventerebbe ancora più fastidioso.
Ho un’altra scappatoia che non mi soddisfa pienamente (la tua è molto meglio e quasi quasi la adotto). Siccome il template che ho creato si applica alle pagine statiche potrei sostituire la solita riga con:
if ( !$withsidebar && !is_single() && !is_page(LISTA_ID_O_NOMI_DI_OGNI_PAGINA_A_CUI_SI_APPLICA_IL_TEMPLATE) ) {
Mi chiedo però (in mancanza di un tag condizionale specifico) se si possa creare una nuova funtion da chiamare is_template_nome() simile ai tag condizionali is_single(), is_page(), ecc. per modificare come avrei voluto:
if ( !$withsidebar && !is_single() && !is_template_nome() ) {
Sapete in quale file di wordpress sono definiti i tag condizionali: magari si può copiare un po’ di codice da là¬.
Comunque spero in altri suggerimenti Grazie mille!
23 Agosto 2007 alle 16:06 in risposta a: Kubrick, template e if ( !$withcomments && !is_single() ) { #46290oruxPartecipanteHo capito una cosa.
La chiave sta in
if ( !$withcomments && !is_single() ) {
intanto $withcomments è semplicemente una variabile che viene impostata in questo momento e non in un altro, per cui può essere rinominata in qualsiasi modo senza cambiare il risultato.
Il significato del codice è:
Se la pagina che si visualizza (che chiamiamo $withcomments anche se era meglio chiamarla in un altro modo… per esempio $withsidebar) è single
allora usa come sfondo kubrickbg.jpg
altrimenti usa come sfondo kubrickbgwide.jpg
ORA
Io ho creato un template di pagina con un file che si chiama page_lab.php. Ho assegnato al template il nome di “Laboratorio”.
Vorrei modificare questo
if ( !$withcomments && !is_single() ) {
in qualcosa tipo
if ( !$withsidebar && !is_single() && !is_IL_MIO_TEMPLATE_LABORATORIO() ) {
Come faccio a scrivere !is_IL_MIO_TEMPLATE_LABORATORIO() ?
Esiste un tag condizionale per i template?
oruxPartecipanteGrazie, purtroppo però c’è qualcosa di strano.
In effetti nelle impostazioni di firefox avevo impostato
“Visualizza un’anteprima e chiedi quale lettore feed utilizzare”…
Invece impostando il lettore nelle impostazione il feed funziona!
Però QUALCOSA NON FUNZIONA COMUNQUE
Anche mantenendo l’impostazione “Visualizza un’anteprima…”, soltanto nelle pagine degli articoli, l’anteprima viene visualizzata correttamente.
Per esempio in http://www.marialuisafalanga.it/?p=31
Mentre in una qualsiasi pagina statica come http://www.marialuisafalanga.it/?page_id=24
ottengo l’errore di sopra.
E poi per i trackback?
Perché ricevo l’errore anche in questo caso, solo nelle pagine statiche?
Grazie ancora, siete gentilissimi, aspetto fiducioso
oruxPartecipanteCome dicevo, il sito è in locale sul mio computer.
Per cui non è in rete.
A ogni modo, ripensandoci, ho recentemente fatto un sito per una scultrice, basato su WordPress, che ha lo stesso problema.
Ecco una pagina incriminata:
http://www.marialuisafalanga.it/?page_id=24
Potete indicarmi dove intervenire?
Grazie mille!
- <h2>Categorie</h2>
-
AutorePost