bp_get_the_post_class( array $wp_classes = array() )
Customizes the post CSS class according to BuddyPress content.
Description
Hooked to the ‘post_class’ filter.
Parameters
- $wp_classes
-
(Optional) The post classes coming from WordPress.
Default value: array()
Return
(array)
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 ) ); }
Changelog
Version | Description |
---|---|
BuddyPress 2.1.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.