Visualizzazione 4 filoni di risposte
Visualizzazione 4 filoni di risposte
- Devi essere connesso per rispondere a questo topic.
Email: info@wpitaly.it
Home › Forum › Problemi Vari con WP › post più recente con css diverso
Ciao a tutti,
vorrei riuscire ad assegnare una classe dei CSS al post più recente, in modo che appaia diverso dagli altri. In pratica, al primo post finirei per assegnare, ad esempio, una classe “most-recent-post” e alle altre “post”. Inoltre, vorrei far sଠche a ogni categoria, venga assegnata una classe per l’intero blocco del post.
Come faccio a gestirlo nel loop di wordpress? Ho provato con variabili come $i=0 o $count=0, ma non riesco a venirne a capo.
Help.
Edo
Esattamente come hai provato a fare… inizializzi una variabile fuori dal loop a 0 poi cicli dentro il loop fai un if se la variabile è uguale a zero la classe del post sarà “most-recent-post” se no “post”, priam di chiudere il loop incrementi la variabile… come variante visto che devi vedrificare solo una volta metti una variabile a$=”primo” nell’if se a$ è uguale a primo metti la classe per il primo post e poni la variabile a “nonprimo”, da questo momento non passerà mai per l’if perchè non si verificherà più l’eguaglianza e sei a posto.
Ciao Steve,
scusa se ti disturbo di nuovo, ma ho provato ad applicare e non mi funziona nulla.
Non è che mi incolleresti un po’ di codice, cosଠcapisco?
Edo
Ah, la seconda parte “primo” “non primo” non l’ho capita proprio, scusa.
Ok, lasciamo stare, ce l’ho fatta.
Grazie
Edo
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0