Last active
February 15, 2017 01:40
-
-
Save srikat/769fc125b64ab19585a2c2eb4c5697bc to your computer and use it in GitHub Desktop.
Make BuddyPress Members page obey its Page layout setting in Genesis. https://sridharkatakam.com/make-buddypress-members-page-obey-page-layout-setting-genesis/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Make BuddyPress Members page obey its Page layout setting | |
*/ | |
add_filter( 'genesis_pre_get_option_site_layout', 'sk_do_members_page_layout' ); | |
function sk_do_members_page_layout( $opt ) { | |
// if the current page is not the members directory, abort. | |
if ( ! bp_is_members_directory() ) { | |
return; | |
} | |
// get the list of BuddyPress pages from wp_options table | |
$page_array = get_option( 'bp-pages' ); | |
$opt = get_post_meta( $page_array['members'], '_genesis_layout', true ); // where $page_array['members'] is the ID of BuddyPress Members page | |
return $opt; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'genesis_pre_get_option_site_layout', 'sk_do_buddypress_page_layout' ); | |
/** | |
* Make BuddyPress Members and Groups pages obey their Page layout setting | |
*/ | |
function sk_do_buddypress_page_layout( $opt ) { | |
// if the current page is not the members directory or groups page, abort. | |
if ( ! ( bp_is_members_directory() || bp_is_groups_component() ) ) { | |
return; | |
} | |
// get the list of BuddyPress pages from wp_options table | |
$page_array = get_option( 'bp-pages' ); | |
if ( bp_is_members_directory() ) { | |
$opt = get_post_meta( $page_array['members'], '_genesis_layout', true ); | |
// where $page_array['members'] is the ID of BuddyPress Members page | |
} | |
if ( bp_is_groups_component() ) { | |
$opt = get_post_meta( $page_array['groups'], '_genesis_layout', true ); | |
// where $page_array['groups'] is the ID of BuddyPress Groups page | |
} | |
return $opt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to add code that works for both Members and Groups BuddyPress pages.