BP_Groups_Theme_Compat::single_template_hierarchy( string $templates )

Add custom template hierarchy to theme compat for group pages.


Description Description

This is to mirror how WordPress has template hierarchy.


Top ↑

Parameters Parameters

$templates

(string) (Required) The templates from bp_get_theme_compat_templates().


Top ↑

Return Return

(array) $templates Array of custom templates to look for.


Source Source

File: bp-groups/classes/class-bp-groups-theme-compat.php

	public function single_template_hierarchy( $templates ) {
		// Setup some variables we're going to reference in our custom templates.
		$group = groups_get_current_group();

		/**
		 * Filters the Groups single pages template hierarchy based on priority.
		 *
		 * @since 1.8.0
		 *
		 * @param array $value Array of default template files to use.
		 */
		$new_templates = apply_filters( 'bp_template_hierarchy_groups_single_item', array(
			'groups/single/index-id-'     . (int) bp_get_current_group_id()                   . '.php',
			'groups/single/index-slug-'   . sanitize_file_name( bp_get_current_group_slug() ) . '.php',
			'groups/single/index-action-' . sanitize_file_name( bp_current_action() )         . '.php',
			'groups/single/index-status-' . sanitize_file_name( $group->status )              . '.php',
			'groups/single/index.php'
		) );

		// Merge new templates with existing stack.
		// @see bp_get_theme_compat_templates().
		$templates = array_merge( (array) $new_templates, $templates );

		return $templates;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.