Home › Forum › Plugin e temi di WP › Gestire news con Query_post in orizzontale e con icona associata
-
AutorePost
-
-
27 Agosto 2008 alle 15:16 #7694CatonePartecipante
Un po’ arruginito dalle vacanze mi sono rimesso al lavoro e sono bloccato alla ricerca di realizzare quanto potete vedere in questa immagine:
In pratica vorrei piazzare con query_post le ultime due news in orizzontale, con una immagine di fianco (che non cambia al variare delle news, ovviamente fosse possibile ne sarei entusiasta) e dovrebbero essere dotate di data, titolo, ultime tre righe del post e, eventualmente, del link maggiori informazioni con relativa iconcina (al limite posso rinunciarvi utilizzando il titolo della news come link).
Ora nel loop posso specificare giustamente dei li flottanti e certamente sono in grado di pubblicare titolo e data ma non ho idea/riesco a ricordare di come far comparire l’estratto. Poi c’è il problema delle immagini. Se queste sono due dovrei essere costretto a creare due loop: al primo dico di prendere l’ultima notizia, ma come faccio a dire al secondo di prendere la penultima?
Inoltre l’eventuale link maggiori informazioni come potrebbe essere realizzato?
Grazie a tutti.
-
27 Agosto 2008 alle 15:23 #57103wollyAmministratore del forum
per il riassunto usi the_excerpt
per le immagini usi un plugin tipo custom field image (devi associare un immagine ad ogni post).
-
27 Agosto 2008 alle 19:23 #57130SteveAglAmministratore del forum
Non devi creare due Loop e nemmeno usare
query_posts
, basta il Loop di default. Con l’approccio descritto quihttp://www.wpitaly.it/wiki/Main/FaqGenerali#toc9
riesci a tracciare il ciclo che ti stampa gli articoli. Sapere se un post è il penultimo o l’ultimo è facile:
$quanti_post = count($posts);
$penultimo = $quanti_post - 1;
$i=1;
while (have_posts()) : the_post(); // parte il Loop
// qui ti prendi i campi personalizzati etc...
if ($i < $penultimo){
// codice post normali
}
elseif ($i == $penultimo){
// codice del penultimo post
}
elseif ($i > $penultimo){
// codice ultimo post
}
$i++;
endwhile; // fine del Loop
-
27 Agosto 2008 alle 20:47 #57135CatonePartecipante
grazie mille a tutti, sଠgiustamente con un po’ di php si risolve.
Grazie ancora.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.