Ci sono diversi codici php per visualizzare gli ultimi post di una categoria nella vostra sidebar oppure nel template delle vostre pagine.
Vi riporto alcuni esempi:
<?php $myposts = get_posts('numberposts=5&category=3'); foreach($myposts as $post) : ?> <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php setup_postdata($post); ?> <?php the_content(''); ?> <?php endforeach; ?> |
Con questo codice php avremo gli ultimi 5 post, compresi di contenuto, della categoria con ID=3.
Quindi per modificare il numero di post da visualizzare, al posto del numero 5 inserite il vostro numero, mentre per cambiare l’ID della categoria modificate il numero 3.
get_posts('numberposts=5&category=3'); |
<?php $myposts = get_posts('numberposts=5&category=3'); foreach($myposts as $post) : ?> <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php setup_postdata($post); ?> <?php endforeach; ?> |
In pratica ho cancellato:
<?php the_content(''); ?> |
Popularity: 3% [?]
Sono stati inviati 0 commenti - Lascia un commento
Lascia un commento