Getting a consistent look
-
Hey there,
I have installed BP & WPMU now for a couple days and thought I’d share a few points I had trouble with. All of them have to do with getting the same look throughout your site.
First of all, I copied header.php into my child theme and changed the links in the main menu. The main menu makes use of this bit quite a lot:
echo get_option('home')
.I changed this to
echo SV_HOME_LINK
and added this line to my themes functions.php:if( ! defined('SV_HOME_LINK') ) define( 'SV_HOME_LINK' , 'http://sv.localhost' );
This does two things. It makes sure that the links in the menu always point to the same location, which they would not have from another blog except the main and I only have to change the value of SV_HOME_LINK once (in functions.php) instead of a few times in the header.php file when I move everything to a production server.
The next thing I wanted was a prominent logout link in the admin bar.
function sv_add_adminbar()
{
if ( is_user_logged_in() )
{
echo '<li id="logout-bar" class="no-arrow">';
bp_log_out_link();
echo '</li>';
}
}
add_action( 'bp_adminbar_menus', 'sv_add_adminbar', 14 );Put the above function into your functions.php file and it’s sorted.
I also wanted every new blog to use the same default theme from the start and I don’t want to call that theme ‘default’, cause it gets overwritten when you update WPMU. This little function (placed in bp-custom.php) takes care of that (you have to replace sv with the name of your stylesheet):
function sv_change_template( $blog_id )
{
switch_to_blog( $blog_id );
update_option('template', 'bp-sn-parent');
update_option('stylesheet', 'sv');
restore_current_blog();
}
add_action( 'wpmu_new_blog', 'sv_change_template' );All seemed to be well. I installed a test user with a test blog and his blog posts showed up, but his index file was empty, so I had a look at home.php. This is the code I had in that file after fiddling with it before already:
get_header();
if( is_user_logged_in() ) {
//here I have a widget area and a sidebar shown only to logged in users
} else {
// here's the code for logged out users, like random members, login form
// and the latest post from the main blog
}
get_footer();I needed the homepage of every blog to show an index of their posts, so I changed the above code to this:
get_header();
// only do the following for the site homepage
if( is_main_blog() ) {
if( is_user_logged_in() ) {
//here I have a widget area and a sidebar shown only to logged in users
} else {
// here's the code for logged out users, like random members, login form
// and the latest post from the main blog
}
// and this bit for every other blog
} else {
// here I put the normal loop from index.php plus the sidebar
}
get_footer();That was basically it. I did some more stuff, but that was all specific to the site I’m setting up. Never having looked at BP or WPMU before it took me the better part of two days to figure out the above things, so I thought I share them to make it easier for others.
Enjoy!
Boris
- The topic ‘Getting a consistent look’ is closed to new replies.