bp_groups_get_front_template( BP_Groups_Group|null $group = null )
Locate a custom group front template if it exists.
Description
Parameters
- $group
-
(Optional) Falls back to current group if not passed.
Default value: null
Return
(string|bool) Path to front template on success; boolean false on failure.
Source
File: bp-groups/bp-groups-template.php
5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 | function bp_groups_get_front_template( $group = null ) { if ( ! is_a ( $group , 'BP_Groups_Group' ) ) { $group = groups_get_current_group(); } if ( ! isset( $group ->id ) ) { return false; } if ( isset( $group ->front_template ) ) { return $group ->front_template; } $template_names = array ( 'groups/single/front-id-' . sanitize_file_name( $group ->id ) . '.php' , 'groups/single/front-slug-' . sanitize_file_name( $group ->slug ) . '.php' , ); if ( bp_groups_get_group_types() ) { $group_type = bp_groups_get_group_type( $group ->id ); if ( ! $group_type ) { $group_type = 'none' ; } $template_names [] = 'groups/single/front-group-type-' . sanitize_file_name( $group_type ) . '.php' ; } $template_names = array_merge ( $template_names , array ( 'groups/single/front-status-' . sanitize_file_name( $group ->status ) . '.php' , 'groups/single/front.php' ) ); /** * Filters the hierarchy of group front templates corresponding to a specific group. * * @since BuddyPress 2.4.0 * @since BuddyPress 2.5.0 Added the `$group` parameter. * * @param array $template_names Array of template paths. * @param object $group Group object. */ return bp_locate_template( apply_filters( 'bp_groups_get_front_template' , $template_names , $group ), false, true ); } |
Changelog
Version | Description |
---|---|
BuddyPress 2.6.0 Adds the Group Type to the front template hierarchy. | BuddyPress 2.6.0 Adds the Group Type to the front template hierarchy. |
BuddyPress 2.4.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.