So here I am, a total PHP newbie trying to make my first plugin. Disaster ensues...
The idea is to have a "recent posts" like widget where I could, at a later stage, highlight some of the posts according to the category. I'm not there yet, I'm only currently trying to have the "recent posts" thing working.
Emphasis on "trying": every time I try to activate the plugin, the whole installation goes blank. Deleting the plugin from the folder reverts things to normal again, thankfully!
Of course, being a total nerwbie, I'm stumped. Any help would be appreciated, including pointers to reference pages and tutorials.
<?php
/**
* Plugin Name: LWF Recent Posts
* Plugin URI: http://test2.lutheranworld.org/wordpress/
* Description: A variant of the "recent post" widget, adding a "(LWI)" label to news stories
* Version: 0.1
* Author: LWF/Stephane Gallay
* Author URI: http://www.lutheranworld.org
*/
class LWF_Widget extends WP_Widget {
function LWF_Widget() {
parent::WP_Widget(false, $name = 'LWF Recent Posts');
}
function widget($args, $instance) {
extract ( $args );
$recentPosts = new WP_Query();
$recentPosts->query('showposts=5');
?>
<h3>Recent Articles</h3>
<ul>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php
// What the widget will output in the front-end
}
// When the Widget (No editing needed)
function update($new_instance, $old_instance) {
return $new_instance;
}
function form($instance) {
// Widget Settings en the widgets back-end
}
}
register_widget('LWF_Widget'); // This adds the Widget to the backend
?>
Many thanks in advance!