Wordpress – Posts – Lista dei post recenti
Lista dei post recenti | solo titolo
Aggiungiamo automaticamente una lista con i post recenti:
1. Apriamo con un software FTP nel server la cartella che contiene il nostro tema WoprdPress, ad esempio:
blog/wp-content/themes/miotema
2. Apriamo il file:
blog/wp-content/themes/miotema/single.php che contiene il template per il singolo articolo e aggiungiamo le righe:
1 2 3 | <! -- Get Recent Posts START --> <?php wp_get_archives( array ( 'type' => 'postbypost' , 'limit' => 10, 'format' => 'html' ) ); ?> <! -- Get Recent Posts END --> |
limit’ => 10 : il numero massimo di post da visualizzare
Il risultato sarà un elenco puntato dal post più recente a quello più vecchio.
Lista dei post recenti | titolo + sommario
1 2 3 4 5 6 7 8 9 | <! -- Get Recent Posts START --> <ul> <?php $the_query = new WP_Query( 'showposts=5' ); ?> <?php while ( $the_query -> have_posts()) : $the_query -> the_post(); ?> <li><a href= "<?php the_permalink() ?>" ><?php the_title(); ?></a></li> <li><?php the_excerpt(__( '(more…)' )); ?></li> <?php endwhile ;?> </ul> <! -- Get Recent Posts END --> |
showposts=5 : numero di post mostrati