|
46 | 46 |
|
47 | 47 | <?php while ( have_posts() ) : the_post(); ?>
|
48 | 48 |
|
| 49 | +<?php |
| 50 | +$parent = get_post($post->post_parent); |
| 51 | +$grandparent = get_post($parent->post_parent); |
| 52 | +$aunts = get_children($grandparent->ID); |
| 53 | +?> |
| 54 | + |
49 | 55 | <header>
|
50 | 56 |
|
51 | 57 | <nav class="breadcrumbs">
|
|
61 | 67 | <?php endif; ?>
|
62 | 68 |
|
63 | 69 | <?php if ($contextType != 'course-index' ) : ?>
|
64 |
| - <li><a href="#">top title of course</a></li> |
| 70 | + <li><a href="<?php the_permalink($grandparent->ID); ?>"><?php echo $grandparent->post_title; ?></a></li> |
| 71 | + |
| 72 | + |
65 | 73 | <?php endif; ?>
|
66 | 74 |
|
67 | 75 | </ul>
|
|
76 | 84 |
|
77 | 85 | </header>
|
78 | 86 |
|
| 87 | + |
79 | 88 | <div class="content">
|
80 | 89 |
|
81 | 90 |
|
82 | 91 | <?php the_content(); ?>
|
83 | 92 |
|
| 93 | +<?php |
| 94 | + |
| 95 | +// find previous & next siblings, if present |
| 96 | +if (has_post_parent()) { |
| 97 | + $siblings = get_children($post->post_parent); |
| 98 | + |
| 99 | + foreach ($siblings as $sibling ){ |
| 100 | + if ($sibling->menu_order == $post->menu_order - 1) { |
| 101 | + $previousLink = get_permalink($sibling->ID); |
| 102 | + } |
| 103 | + |
| 104 | + if ($sibling->menu_order == $post->menu_order + 1) { |
| 105 | + $nextLink = get_permalink($sibling->ID); |
| 106 | + } |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | +if ($previousLink == '') { |
| 111 | + |
| 112 | + foreach ($aunts as $aunt) { |
| 113 | + |
| 114 | + if ($aunt->menu_order == $parent->menu_order - 1) { |
| 115 | + |
| 116 | + $cousins = get_children($aunt->ID); |
| 117 | + |
| 118 | + foreach ($cousins as $cousin) { |
| 119 | + if ($cousin->menu_order == count($cousins)) { |
| 120 | + $previousLink = get_permalink($cousin->ID); |
| 121 | + } |
| 122 | + |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +if ($nextLink == '' && $contextType == 'course-page') { |
| 129 | + |
| 130 | + foreach ($aunts as $aunt) { |
| 131 | + |
| 132 | + if ($aunt->menu_order == $parent->menu_order + 1) { |
| 133 | + |
| 134 | + $cousins = get_children($aunt->ID); |
| 135 | + |
| 136 | + foreach ($cousins as $cousin) { |
| 137 | + if ($cousin->menu_order == 1) { |
| 138 | + $nextLink = get_permalink($cousin->ID); |
| 139 | + } |
| 140 | + |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | +} |
| 145 | + |
| 146 | +?> |
84 | 147 |
|
85 | 148 | </div>
|
86 | 149 |
|
| 150 | +<?php if ($previousLink != '' || $nextLink != '') : ?> |
| 151 | +<nav class="pagination" aria-label="Pagination"> |
| 152 | + <ul> |
| 153 | + <?php if ($previousLink != '') : ?> |
| 154 | + <li><a href="<?php echo $previousLink; ?>">Previous</a></li> |
| 155 | + <?php endif; ?> |
| 156 | + |
| 157 | + <?php if ($nextLink != '') : ?> |
| 158 | + <li><a href="<?php echo $nextLink; ?>">Next</a></li> |
| 159 | + <?php endif; ?> |
| 160 | + </ul> |
| 161 | +</nav> |
| 162 | +<?php endif; ?> |
| 163 | + |
| 164 | + |
87 | 165 |
|
88 | 166 | <?php endwhile; // end of the loop. ?>
|
89 | 167 | </main>
|
|
0 commit comments