Getting Ajax to Work in WPMU + BuddyPress

In the latest release of BP, themes are integrated site-wide, so I’m finally getting around to making a custom WPMU+BP theme. came across a problem that it seems like others are having too. For example, on the main Members page, clicking on one of the letters under Member Directory did not refresh the page. I knew that javascript was responsible, but with all the different customization locations (mu-plugins, bp-custom, plugins, theme functions) it took me a while to figure out where themes like BP-Corporate were initiating the jquery from (this was the BP theme I folded into my custom WP theme). Turns out it’s the (then bp-theme, *now* unified theme) theme’s functions.php file.

Anyway, if you’re having trouble getting other jquery BP stuff working, this will work for the usual components, including the Members Directory alphabetical sorting links.

There’s 2 steps:

  1. Open your theme’s functions.php and add the following lines before the final ?>
    /* Load the AJAX functions for the theme */
    require_once( TEMPLATEPATH . '/_inc/ajax.php' );

    /* Load the javascript for the theme */
    wp_enqueue_script( 'jquery-livequery-pack', get_template_directory_uri() . '/_inc/js/jquery-livequery.js', array( 'jquery' ) );
    wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/js/ajax.js', array( 'jquery', 'jquery-livequery-pack' ) );

  2. Be sure to upload the following files to your theme folder (so it’s like ../themes//_inc/…) If you already have an _inc folder, be sure not to overwrite, but upload the files, preserving the hierarchy in this zip: _inc.zip
Erin Bruce