Making a member list blog directory

Sorry for the convoluted title, it’s more for search engines. I’ve found there’s quite a few different ways people phrase what they want, but here’s how to do it. Ultimately, you will wind up with a separate page off the main blog with a list of all your public member blogs.

You will need:
- a copy of List All redux (1080)
- a copy of the page.php file from your main admin blog’s template

Place the list_all plugin in your mu-plugins folder if you have not already done so. Some things to remember are that this plugin does not have an admin menu, so you won’t see any changes on the back end. You’ll have to call it directly to use it, which is good as you don’t want your members making lists too.

Save a copy of your theme’s page.php file to your desktop or working folder on your computer, somewhere that you can find it later. Open it up in your favorite text editor. If I have to work on windows, I like to use jEdit or Notepad++ because the default notepad sometimes screws things up. On Linux, I happen to love gPHPedit because of the code highlighting and the instant visuals if I happen to accidentally delete closing tags.

Allrighty, with the page.php template open in front of you, you should see something like this:

<?php get_header(); ?>

<div id=”content” class=”narrowcolumn”>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<h2><?php the_title(); ?></h2>
<div class=”entry”>
<?php the_content(‘<p class=”serif”>Read the rest of this page »</p>’); ?>

<?php wp_link_pages(array(‘before’ => ‘<p><strong>Pages:</strong> ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>

</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link(‘Edit this entry.’, ‘<p>’, ‘</p>’); ?>
</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

The first thing we are going to do is add some comments at the top, so the system will know it is a new page template and what to call it. Add this at the top of the file:

<?php
/*
Template Name: Member Listing
*/
?>

You don’t have to call it Member Listing, you can call it whatever you like. If you read further down in the template, there is a div next, then the Loop. That’s the code that pulls in the actual content of the page. In this case, we don’t want it. Delete everything from <?php if (have_posts to <?php edit_post_link(‘Edit this entry.’, ‘<p>’, ‘</p>’); ?>. Your page template should look pretty empty.

Now here comes the good stuff; insert the code from the list_all plugin to generate our list of member blogs. This plugin has a few options that you can play with too, but for now you’ll tell it to pull a full listing of blogs in alphabetical order. The function for that is this:

<?php list_all_wpmu_blogs(’500′, ‘name’, ”, ‘<br />’, ‘blog_name’); ?>

Paste that between the opening and closing content div tags, replacing the Loop that you just removed. It should look something like this:

<?php
/*
Template Name: Member Listing
*/
?>
<?php get_header(); ?>

<div id=”content” class=”narrowcolumn”>
<?php list_all_wpmu_blogs(’500′, ‘name’, ”, ‘<br />’, ‘blog_name’); ?>
</div>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

The paramaters passed are the detail in brackets to tell it to show 500 blogs, displayed by name, no HTML in front and a carriage return after each, sorted by name. Please note that this plugin will not display blogs that are listed as private. They have to be set to public to show up.

Now, save your template as a new file, called something like members.php or even listing.php, as long as it doesn’t interfere with other template files. Upload this new template file to your mu site to your main blog’s theme folder; ie – wp-content/themes/yourmainblogtheme/

Login to MU at the main blog and go to Write Page. Choose a title for your new page, such as “Member Listing”. Don’t write any text in the post area, as we’ve taken out the code to make it show up. Here’s the important bit though: down the right side, there should now be a blue bar there that says “Page template”. Expand it and have a look at the drop-down box. There should be a list that says “default template” and right under it the name of the new page template we just created; in this case it says “members” or whatever you saved the file as. Select this template and publish the page.

If you’ve chosen a particularly nice theme, there will likely be a navigation bar that automatically pulls in page names for menu items. You’ll find your new page there.

Last but not least, make sure your main blog theme is not accessable to your users by following the instructions here.

Based on instruction from Creating your own page templates from the WordPress Codex. If you just scrape the code from this page and copy and paste it, the formatting will be off. So type it in. :)

Don’t forget to leave me a comment and show off your new page-making skills. You can see mine here.

Comments

  1. The problem with that, and I notice it when I try to pull up your example, is that the data is not cached in any way. It’s a fresh copy every single time which is going to cause processor strain and long delays. Took about 90 seconds for your example page to come up.

    A better idea, no offense Andrea, would be create the output once an hour or so via a cron job and either dump it into a static page or into a database as a single record and use that.

    • You probably wouldn’t want to install it just for this reason, but WP-Super-Cache takes care of this issue… This page is cached just like the other blog posts.

      Downside of course is the list won’t reflect a newly created blog straight away, but certainly removes the load issue!

      • That only applies with wp-super-cache running in full static page mode. I know we’re not running wp-super-cache in full mode as it causes too many issues. (ie Too many plugins fails, mobile support doesn’t work, releasing the cache doesn’t always occur when changes to the blog are made, etc.) I know on all of my installs, wp-super-cache is only running in half mode. Even in half mode, this would still be a bad idea because the plugin isn’t setup to save it;s data anywhere. (At least last time I looked.)

        We actually do something along what I suggested and save the data for ‘x’ amount of minutes within either a sitewide mate option record or another database within the table. You’ll note further down in one of my other comments, I make the suggestion as how get_sitestats saves it’s data.

        Running this script each and every time isn’t the way to do it though. (No offense, Andrea.)

        • Feel free to write up a new tutorial.

          If you don’t like how the list-all plugin grabs data, take it up with the plugin dev.

  2. Good tip though. :) Maybe I’ll write up that next. :D

    Actually, that highlights issues the new MU site owner might never think of until the first server crash.

  3. Another way to do it is like how mu generates the blog count as it only gets updated once an hour. Take a look within wp-includes/wpmu-functions.php for the get_sitestats() function. It saves the data as a site option but will only update it once an hour. That may be another solution/ option here. Save the list as a site option and, if it’s been less than an hour, just grab it out of the site option table. If it’s been more than an hour, recreate the list.

  4. how can i do this with the authors avatar showing up?

  5. Dear Andrea.

    I need to add alphabetically list of blogs where each letter will display in separate page. So, I have page A B C D ….
    As an example you can see hxxp://ii55.com/ at right sidebar (Quick Browse).

    What’s plugin that can do it?

    Thx
    http://www.nggablog.com

  6. thanks andrea , i’m not a programmer and i find my way hardly through those stuff and your post really helped me

    there’s a problem with the code you posted
    ’, ‘blog_name’); ?>

    this code won’t work and will give error when applied to page theme
    ‘, ”, ‘last_created’); ?>
    this one worked fine

    actually there’re other functions in the last variation which could be of a very good help to users specially if applied to theme itself , i’m working on one now and used the above code but limiting it to 10 and it works more than fine

    the other problem is with this plugin itself , it limits the number of blogs shown to X number of blogs and not providing navigation , i think it might take alot of time for the volunteer coders but i think it would be great to see it with categorizing the blogs on the system too

    thanks andrea for your help here and on the forums too
    fouad.fakhr

  7. sorry for sending again but the code didn’t show , it’s about the BEGIN_WRAP parameter in the code you posted
    and the ‘ in the begining of every parameter in the code

  8. After read your blog i think member list blog directory. is necessary for new blogger.. u explain best ways to Making a member list blog directory step by step. ..it’s very useful method for me……thxx…………keep it up..:):):)

  9. Will this work with ordinary wordpress? Can we make it work?

    TIA

  10. The process is similar, but the plugin involved is specifically for WordPressMU.

    For single-install WordPress, try this:
    http://www.cagintranet.com/archive/wp-membership-directory/

  11. Originally Posted By AndreaThe process is similar, but the plugin involved is specifically for WordPressMU.

    For single-install WordPress, try this:
    http://www.cagintranet.com/archive/wp-membership-directory/

    Thanks Andrea, that’s a usefull link.

  12. I am trying to do the this, however use a photo with each blog. Similar to a gravitar I suppose. Any thoughts.

  13. I installed the plugin and followed your instructions, however, the plugin only displays URLs and always sorts in the order created. What would cause this?

    Thanks for any input.

    • As per the instructions.txt of the plugin file:

      To put a list call list_all_wpmu_blogs(LIMIT, DISPLAY, BEGIN_WRAP, END_WRAP, ORDER);

      Parameters:

      LIMIT: can be any number or left blank for unlimited.
      DISPLAY: Can be either ‘name’ which displays the blogs name or ‘url’ which displays the address
      BEGIN_WRAP: html or other code that you would like if front of the generated html. Example: ”
      END_WRAP: html or other code that you would like after the generated html. Example: ”
      ORDER: Can be ‘updated’ which lists blogs by last updated, ‘first_created’ which lists blogs by the first blog to the latest, or ‘last_created’ which lists blogs from the latest to the first created

  14. Thanks for these easy to follow directions! Awesome!

  15. syamsul says:

    Can’t seem to get this working in WPMU 2.8.1. Hope an update will be coming soon! :)

  16. Hi I seem to be getting an error message

    Parse error: syntax error, unexpected $end in /var/www/html/wpmu/htdocs/wp-content/themes/illustrative/members.php on line 11

    These are the contents of my members.php

    <?php list_all_wpmu_blogs(’100′, ‘name’, “, ”, ‘updated’);
    ?>

    • Oops not sure why the code got cut off – here’s the full contents. Will be grateful for any advice

      <?php list_all_wpmu_blogs(’100′, ‘name’, “, ”, ‘updated’);
      ?>

  17. I am using the thesis theme, and there is no page.php page or anything similar.

    I do have an index.php and custom_template.php file, but the only thing in those files is the line
    thesis_html_framework();

    kinda stumped here

  18. thanks for this tip.

    I only have one blog running off my main page, but i got it to work here:

    http://mba365.com/one-year-mba-schools/

    My main question is this: Any way to exclude the main blog from this listing? AS you can see it is listing ‘mba365′ but i only want to list the other blogs…Thanks!

  19. Parse error: syntax error, unexpected ‘>’ in /home5/yoursup2/public_html/blog/wp-content/themes/multichrome/listing.php on line 27
    is the error I get. I have checked the code a lot but that’s all I get

  20. I just used this on a restaurant directory website we’re doing for a local market. Perfect, even 2+ years after the original post. :D

Trackbacks

  1. [...] es kein einziger professioneller > > > > Designer. Viel Spaß mit dem Schrott. > > > und was ist an macromedia so professionell? ich kenne viele, die das > > > Plugin nicht installiert haben und die supertollen [...]

  2. [...] duh!) I was able to install a little plug-in called list-all and by following the instructions on wpmu tutorials I was easily able to create a page listing all of the public [...]