-
Notifications
You must be signed in to change notification settings - Fork 13
Home
Jared Atchison edited this page Mar 29, 2016
·
4 revisions
/**
* Customize the BE Subpages widget to always show the children and grandchildren
*
* @param array $parents
* @return array
*/
function be_subpages_widget_parents_args( $parents ) {
$pages = get_pages( array( 'child_of' => $parents[0] ) );
foreach ( $pages as $page ) {
$parents[] = $page->ID;
}
return $parents;
}
add_filter( 'be_subpages_widget_parents', 'be_subpages_widget_parents_args' );
/**
* Mark top level as current.
*
* @since 1.0.0
*/
function ja_be_subpages_toplevel( $class, $subpage ) {
global $post;
if ( $subpage->ID == $post->post_parent ) {
$class[] .= 'widget_subpages_current_page';
}
return $class;
}
add_filter( 'be_subpages_widget_class', 'ja_be_subpages_toplevel', 10, 2 );
/**
* Show nav widget on home
*
* @since 1.0.0
*/
function ja_blog_submenu_display( $show ) {
if ( is_home() )
return true;
return $show;
}
add_filter( 'be_subpages_widget_display_override', 'ja_blog_submenu_display' );
/**
* Show nav widget on home
*
* @since 1.0.0
*/
function ja_blog_submenu_post( $post ) {
if ( is_home() )
$post = get_post( get_option( 'page_for_posts' ) );
return $post;
}
add_filter( 'be_subpages_widget_override_post', 'ja_blog_submenu_post' );