ciuncky
Member
Posted 2 months ago #
Hello,
I have a theme that in the footer has the most commented widget. The code looks like that:
<li class="widget">
<h3><?php _e('Most Commented'); ?></h3>
<?php get_hottopics(); ?>
Now, i would like instead of the most commented to appear the latests posts. how should i change the code?
thanks a lot
Either use a Recent Posts plugin or use code similar to:
<li class="widget">
<h3><?php _e('5 recent posts'); ?></h3>
<?php
$args=array(
'showposts'=>5,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
} //if ($my_query)
wp_reset_query(); // Restore global post data stomped by the_post().
?>
ciuncky
Member
Posted 2 months ago #
thanks a lot man...that works :)
the theme wasn't supporting to add different widgets there, so i needed some code :)