Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

WPMU List All Postings Widget

This code is the code needed to create a widget to show a list of on post in each of your blogs. It is dependent on the plug-in List All Posts, that should be installed first. Create a blank text file named widget_list_all_posts.php in your plugins folder, add the following php code. You should them be able to activate the List All Posts plugin and the List-All-Posts Widget on the plugins tab. Then look over in the presentation/widgets tab and you should have a new widget named List All Posts Widget.

<?php
/*
Plugin Name: List-All-Postings Widget
Plugin URI: http://codex.wordpress.org/WPMU_List_All_Postings_Widget
Description: Creates a list of all posts on a WPMU site as a widget, conversion from previous version based on code in http://www.erik-rasmussen.com/blog/2006/11/30/widgetize-anything/
Author: Unkown - last edited Iolaire McFadden 
Author URI: http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
Version: 0.0.1
*/

function widget_list_all_posts_init() {
	if ( !function_exists('register_sidebar_widget') )
		return;


	function widget_list_all_posts($args) {
        extract($args);

        if(function_exists(list_all_wpmu_blogs)) {
	                 echo $before_widget;

	                 echo $before_title . 'All Recent Deals' . $after_title;
	                        list_all_wpmu_posts(20, 0, '<p>', '</p>', '<p>', '</p>','show','hide','hide');
	                 echo $after_widget;
	        }
		else 
		{
                 echo "Error - function  list_all_wpmu_blogs not found";
        }
	}
	

    if ( function_exists('wp_register_sidebar_widget') ) // fix for wordpress 2.2.1
      wp_register_sidebar_widget(sanitize_title('Widgetize list all posts' ), 'Widgetize list all posts', 'widget_list_all_posts', array(), 1);
    else
      register_sidebar_widget('Widgetize list all posts', 'widget_list_all_posts', 1);
}
add_action('plugins_loaded', 'widget_list_all_posts_init');
?>