forked from tareq1988/wedocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-docs.php
55 lines (47 loc) · 1.83 KB
/
single-docs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
global $post;
$skip_sidebar = get_post_meta( $post->ID, 'skip_sidebar', true );
?>
<div class="row wedocs-single-wrap">
<?php if ( $skip_sidebar != 'yes' ) { ?>
<div class="col-sm-3">
<aside class="widget doc-nav-widget">
<?php
$ancestors = array();
$root = $parent = false;
// $ancestors = get_post_ancestors( $post->ID );
// var_dump( $ancestors );
if ( $post->post_parent ) {
$ancestors = get_post_ancestors($post->ID);
$root = count($ancestors) - 1;
$parent = $ancestors[$root];
} else {
$parent = $post->ID;
}
// var_dump( $parent, $ancestors, $root );
$walker = new WeDocs_Walker_Docs();
$children = wp_list_pages( array(
'title_li' => '',
'order' => 'menu_order',
'child_of' => $parent,
'echo' => false,
'post_type' => 'docs',
'walker' => $walker
) );
?>
<h3 class="widget-title">
<?php echo get_post_field( 'post_title', $parent, 'display' ); ?>
</h3>
<?php if ($children) { ?>
<ul class="doc-nav-list list-unstyled">
<?php echo $children; ?>
</ul>
<?php } ?>
</aside>
</div>
<?php } ?>
<div class="col-sm-<?php echo $skip_sidebar == 'yes' ? '12 skip-sidebar' : 9; ?> wedocs-single-content">
<?php wedocs_breadcrumbs(); ?>
<?php get_template_part('templates/content', 'single'); ?>
</div>
</div>