Skip to content

Instantly share code, notes, and snippets.

@darkiop
Created May 4, 2019 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkiop/ab8cefde05d58e985fe9f04367eeef66 to your computer and use it in GitHub Desktop.
Save darkiop/ab8cefde05d58e985fe9f04367eeef66 to your computer and use it in GitHub Desktop.
<?php
if ( ( is_single() || is_page() ) && 'et_full_width_page' === get_post_meta( get_queried_object_id(), '_et_pb_page_layout', true ) )
return;
?>
<?php
if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
<div id="sidebar">
<?php
if (!is_search() && !is_404()) :
if (!$post->post_parent) {
$ancestor_title = get_post($post);
$ancestor_title = $ancestor_title->post_title;
if (DEBUG_STW == 1) :
debugVar($ancestor_title, '$ancestor_title');
endif;
}
if ($post->ancestors) {
$ancestor_title = $post->ancestors;
$ancestor_title = end($ancestor_title);
$ancestor_title = get_the_title( $ancestor_title );
if (DEBUG_STW == 1) :
debugVar($ancestor_title, '$ancestor_title');
endif;
}
if (!$post->post_parent){
// will display the subpages of this top level page
$args = array(
'title_li' => '',
'child_of' => $post->ID,
'echo' => 0,
'sort_column' => 'post_title'
);
$children = wp_list_pages($args);
if (DEBUG_STW == 1) :
debugVar($children);
endif;
} else {
$ancestors = get_post_ancestors( $post->ID );
if (DEBUG_STW == 1) :
debugVar($ancestors);
endif;
$ancestors = end($ancestors);
$args = array(
'title_li' => '',
'child_of' => $ancestors,
'echo' => 0,
'sort_column' => 'post_title'
);
$children = wp_list_pages($args);
if (DEBUG_STW == 1) :
debugVar($children);
endif;
}
if (DEBUG_STW == 1) :
debugVar($ancestor_title, "ancestor_title");
endif;
if ($children) { ?>
<div id="sidebar-submenu" class="et_pb_widget widget_submenu">
<h4 class="widgettitle"><?php echo $ancestor_title; ?></h4>
<div class="textwidget">
<ul class="list-group">
<?php echo $children; ?>
</ul>
</div>
</div>
<?php
}
endif;
?>
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div> <!-- end #sidebar -->
<?php endif; //if (!is_search() && !is_404())?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment