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 › Mostrare gli ultimi post
Buongiorno,
avrei la necessità di mostrare gli ultimi 5 post di una categoria.
Al momento utilizzo questo:
<?php $recent = new WP_Query(“cat=6&showposts=5); while($recent->have_posts()) : $recent->the_post();?>
Il fatto è che vorrei che i primi 2 fossero per intero mentre gli altri 3
venisse visualizzato solo il titolo cliccabile
Come posso fare ?
nel loop metti un contatore e a seconda che sia inferiore a 3 o uguale o superiore eseguirai codice diverso uno mostrerà anche il the content l’altro solo il titolo..
Ciao,
potresti mettermi un esempio di codice base ?
Non ho ben capito come eseguire il contatore…
Prima del Loop (http://www.wpitaly.it/wiki/Main/IlLoop) metti una variabile inizializzata ad 1 $contatore=1
Poi nel loop avrai una cosa del tipo:
Inizio loop
if $contatore < 3
codice che stampa l’articolo con il testo
else
codice che stampa l’articolo senza testo ma solo titolo
endif
$contatore = $contatore+1
fine del loop
Ho risolto utilizzando la funzione offset, grazie per l’aiuto.
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0