The MU forums have moved to

How do you add the WPMU "List All..." widgets found in the Codex? (4 posts)

  1. DanYork
    Posted 16 years ago #

    I have WPMU 1.3 installed and everything seems to be working fine. On the main "portal" page (when you go to the main site), I would like to add a list of all the blogs on the site as well as a list of recent posts from across all blogs.

    In the WordPress Codex there are the following widgets listed that would seem to provide what I am seeking: (listed as untested)

    However, I can't seem to get this code to work.

    - I have tried created a widgets.php file in my mu-plugins directory. That gave me an error that register_sidebar_widget was not a known function.

    - I tried putting a similar file in plugins and that didn't work either.

    - I tried editing the widgets.php file in the wp-admin directory and this, too, did not work.

    In further searching around (grep is your friend), I can't find a 'register_sidebar_widget' function but there is a 'wp_register_sidebar_widget' function that looks like it takes different parameters (and I did try modifying the widget code but that didn't work). The widget code snippets also seem to call functions that don't appear in the code base such as 'list_all_wpmu_posts'... at least, I couldn't find such a function in the code when I searched it.

    So at this point I am led to conclude that either:

    1. There is some place else I need to put this.
    2. These code snippets rely on some other plugin or add-on that I don't have installed with WPMU 1.3.
    3. These code snippets are for an older version of WPMU, perhaps one that relied on the widgets plugin when it was needed and won't work with WPMU 1.3.

    In my ideal world, I would like these functions not as sidebar widgets but as something that I could put on the main home page. However, I'd also like the "List All Blogs" as a widget that I can put onto each of the sidebars of the blogs in the site (there will only be 5-20 blogs). Right now I'll take whatever I can get!

    Any help or suggestions would be greatly appreciated.


  2. andrea_r
    Posted 16 years ago #

    You are making this far, far too complicated.

    Those chunks of code? make an empty file in your mu-plugins folder. Call it list_all_posts. Copy the code from that codex page and paste it in that file you just made. Save it.

    That's it. It now will magically appear in your widgets list.

    Now that I read the code involved they DO rely on a couple of exisiting plugins:

    Which, really - you can use thsoe plugins I just linked without bothering with the code liste din the codex - that's just to make those elements widgetized.

    Whoever did those stubs needs to go back and add some clear directions, and not just plunk in random code snippets.

  3. DanYork
    Posted 16 years ago #

    andrea_r - I *love* it when someone is telling me that I'm making something far too complicated! That's the problem when you turn a former developer loose on a code base he doesn't yet understand!

    Thanks for the pointer to those two plugins. I've now installed them and they do pretty much exactly what I want. (Well, I'd like an alpha-sorted list of blogs, but I've raised that question on the blog of the developer, and I won't complain given how much I paid for the plugin!)

    For a variety of reasons, I *would* like to have them widgetized for a theme I'm building, but unfortunately the code *as written* in the Codex dies in WPMU 1.3:
    Fatal error: Call to undefined function: register_sidebar_widget() in /var/www/html/wpmu/wp-content/mu-plugins/list_all_widgets.php on line 13
    This seems odd given that other code for widgets does seem to call this same function.

    Anyway, thanks for the help with the pointers to the plugins.

  4. iolaire
    Posted 16 years ago #

    Dan, I've been having the same problem, your post made me look at it again, here is the fix:

    Plugin Name: List-All-Blogs Widget
    Plugin URI:
    Description: Creates a list of all blogs on a WPMU site as a widget, conversion from previous version based on code in
    Author: Unkown - last edited Iolaire McFadden
    Author URI:
    Version: 0.0.1
    function widget_list_all_blogs_init() {
    	if ( !function_exists('register_sidebar_widget') )
    	function widget_list_all_blogs($args) {
            if(function_exists(list_all_wpmu_blogs)) {
                     echo $before_widget;
                     echo $before_title . 'All Blogs' . $after_title;
                            echo "<ul>\n";
                            list_all_wpmu_blogs('100', 'name', '<li>', '</li>', 'updated');
                            echo "</ul>\n";
                     echo $after_widget;
                     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 blogs' ), 'Widgetize list all blogs', 'widget_list_all_blogs', array(), 1);
          register_sidebar_widget('Widgetize list all blogs', 'widget_list_all_blogs', 1);
    add_action('plugins_loaded', 'widget_list_all_blogs_init');

About this Topic