Basic Latest posts widget for WordPress
You can develop as you want. Soon I’ll add more options to this widget making it more useful pluginized widget for WordPress.
/*
Plugin Name: Latest Posts by NB
Plugin URI: http://www.naml-studio.co.cc
Description: Plugin for displaying latest posts
Author: Nurdin Bekkeldiev
Version: 1.0
Author URI: http://www.naml-studio.co.cc
*/
function widget_latestPosts($args, $instance = 'Latest Posts') {
extract($args);
echo $before_widget;
echo $before_title;
echo $instance;
echo $after_title;
getLatestPosts();
echo $after_widget;
}
function latestPosts_init()
{
register_sidebar_widget(__('Latest Posts by NB'), 'widget_latestPosts');
}
function getLatestPosts()
{
$lat_posts = new WP_Query("showposts=5");
echo "<div class='inside'>\n";
echo "<ul class='posts'>\n";
while ( $lat_posts->have_posts() )
{
$lat_posts->the_post();
?>
<li>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</li>
<?php
}
echo "</ul>";
echo "</div>\n";
}
add_action("plugins_loaded", "latestPosts_init");

