Skip to content

Instantly share code, notes, and snippets.

@imjjss
Created February 24, 2012 18:02
Show Gist options
  • Save imjjss/1902440 to your computer and use it in GitHub Desktop.
Save imjjss/1902440 to your computer and use it in GitHub Desktop.
custom Front Page for BuddyPress Groups
http://wordpress.org/extend/plugins/easy-post-types/
Step 1: Download this plugin WP easy post types and activate.
Step 2: Create a post type called Groups
Click the drop down and add new. Add a new post type with the title of a groups slug. Example: say you have a group slug like this groups/bp-tricks, you would then create a group custom type post titled bp-tricks. Add something to the post editor box and hit save.
Important: If you’ve changed the slug of your Groups make sure to use the same name for your Post type!
What we are essentially doing is tricking WP and BP into using the same URL. So by creating a custom post type with the exact URL of a group we can override the front page with a WP page and then use the post editor to create anything.
Step 4: Edit a Template
Go in to your theme folder and open groups/single/home.php
**EDIT LINE 41**
<?php elseif ( bp_group_is_visible() && bp_is_active( 'activity' ) ) : ?>
to
<?php elseif ( !bp_group_is_visible() ) : ?>
Step 5: Create a new template file
In the same folder groups/single/ create a file called front.php and add the following code and save:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>
<?php else icon confused Creating a custom Front Page for your BuddyPress Groups >
<?php locate_template( array( 'groups/single/activity.php' ), true ) ?>
<?php endif; ?>
Conclusion
Now when you visit a group it will show the custom post type page instead of the activity stream. There are some issues with the Home tab and i’m going to suggest a core change to make the tabs easier to customize.
In the mean time you could use this code to change the Home tab to activity, add this to bp-custom.php:
<?php
function my_bp_group_overrides() {
global $bp;
$bp->bp_options_nav['groups']['home']['name'] = 'Activity';
}
add_action('get_header', 'my_bp_group_overrides');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment