bp_get_the_post_class( array $wp_classes = array() )

Customizes the post CSS class according to BuddyPress content.


Description Description

Hooked to the ‘post_class’ filter.


Top ↑

Parameters Parameters

$wp_classes

(array) (Optional) The post classes coming from WordPress.

Default value: array()


Top ↑

Return Return

(array)


Source Source

File: bp-core/bp-core-template.php

function bp_get_the_post_class( $wp_classes = array() ) {
	// Don't do anything if we're not on a BP page.
	if ( ! is_buddypress() ) {
		return $wp_classes;
	}

	$bp_classes = array();

	if ( bp_is_user() || bp_is_single_activity() ) {
		$bp_classes[] = 'bp_members';

	} elseif ( bp_is_group() ) {
		$bp_classes[] = 'bp_group';

	} elseif ( bp_is_activity_component() ) {
		$bp_classes[] = 'bp_activity';

	} elseif ( bp_is_blogs_component() ) {
		$bp_classes[] = 'bp_blogs';

	} elseif ( bp_is_register_page() ) {
		$bp_classes[] = 'bp_register';

	} elseif ( bp_is_activation_page() ) {
		$bp_classes[] = 'bp_activate';
	}

	if ( empty( $bp_classes ) ) {
		return $wp_classes;
	}

	// Emulate post type css class.
	foreach ( $bp_classes as $bp_class ) {
		$bp_classes[] = "type-{$bp_class}";
	}

	// Okay let's merge!
	return array_unique( array_merge( $bp_classes, $wp_classes ) );
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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