Skip to content

Commit 9f480a5

Browse files
committed
learn.jquery.com: Show post heirarchy for context. Fixes jquery/learn.jquery.com#227.
1 parent d228820 commit 9f480a5

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

themes/jquery/css/base.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2792,6 +2792,9 @@ footer li img {
27922792
opacity: 1;
27932793
}
27942794

2795+
.post-heirarchy {
2796+
margin-bottom: 0.75em;
2797+
}
27952798

27962799
/* Listing Pages (categories, searches, etc.)
27972800
========================================================================== */

themes/jquery/functions.jquery.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,23 @@ function jq_banner() {
183183
'jquery_portland_banner_' . $site_color . '.png">' .
184184
'</a>';
185185
}
186+
187+
function jq_post_heirarchy() {
188+
global $post;
189+
$current = $post;
190+
$parents = array();
191+
while ( $current->post_parent ) {
192+
$current = get_post( $current->post_parent );
193+
$parents[] = '<a href="' . get_permalink( $current->ID ) . '">' .
194+
$current->post_title . '</a>';
195+
}
196+
197+
if ( empty( $parents ) ) {
198+
return '';
199+
}
200+
201+
return '' .
202+
'<div class="post-heirarchy">' .
203+
'Posted in: ' . implode( ' > ', array_reverse( $parents ) ) .
204+
'</div>';
205+
}

themes/learn.jquery.com/content-page.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
?>
66

77
<?php $next_prev_arr = get_next_prev_post(); ?>
8+
<?php echo jq_post_heirarchy(); ?>
89
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
910
<header class="entry-header">
1011
<h1 class="entry-title"><?php the_title(); ?></h1>

0 commit comments

Comments
 (0)