From c07b3632e83757591ddcfe8d96c58594d9a48829 Mon Sep 17 00:00:00 2001 From: John Paul Date: Mon, 15 Oct 2012 16:17:59 -0400 Subject: [PATCH] add next and previous buttons to learn pages --- themes/learn.jquery.com/functions.php | 32 +++++++++++++++++++++++++++ themes/learn.jquery.com/page.php | 22 +++++++++++++++++- themes/learn.jquery.com/style.css | 22 ++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/themes/learn.jquery.com/functions.php b/themes/learn.jquery.com/functions.php index 5817dc7f..f8467fb0 100644 --- a/themes/learn.jquery.com/functions.php +++ b/themes/learn.jquery.com/functions.php @@ -10,3 +10,35 @@ function is_subpage() { return false; // ... the answer to the question is false } } + +if ( version_compare( $wp_version, '3.5-alpha', '<' ) ) : + add_filter( 'posts_where_paged', function( $where, $query ) { + global $wpdb; + if ( $menu_order = absint( $query->get( 'menu_order' ) ) ) + $where .= " AND $wpdb->posts.menu_order = " . $menu_order; + return $where; + }, 10, 2 ); +endif; + +function get_next_prev_post() { + global $post; + $menu_order_prev = $post->menu_order - 1; + $menu_order_next = $post->menu_order + 1; + + $posts_prev= new WP_Query( array( + 'post_type' => 'page', + 'post_status' => 'publish', + 'menu_order' => $menu_order_prev + ) ); + + $posts_next= new WP_Query( array( + 'post_type' => 'page', + 'post_status' => 'publish', + 'menu_order' => $menu_order_next + ) ); + + return array( + 'prev' => count($posts_prev->posts) ? $posts_prev->posts[0] : NULL, + 'next' => count($posts_next->posts) ? $posts_next->posts[0] : NULL + ); +} diff --git a/themes/learn.jquery.com/page.php b/themes/learn.jquery.com/page.php index f855ba3d..06b65f78 100644 --- a/themes/learn.jquery.com/page.php +++ b/themes/learn.jquery.com/page.php @@ -1,5 +1,6 @@ - + +
@@ -14,6 +15,25 @@

Suggestions, Problems, Feedback

Open an Issue or Submit a Pull Request on GitHub + +
diff --git a/themes/learn.jquery.com/style.css b/themes/learn.jquery.com/style.css index 44074166..a45dde31 100755 --- a/themes/learn.jquery.com/style.css +++ b/themes/learn.jquery.com/style.css @@ -63,3 +63,25 @@ Template: jquery #body .inner .icon-github { color:#30b9f8; } +#body .inner .bottom-links { + background:lightGray; + overflow:auto; + padding:0px 20px; + clear:left; +} +#body .inner .bottom-links i{ +} +#body .inner .bottom-links a{ + text-decoration:none; +} +#body .inner .bottom-links .prev, #body .inner .bottom-links .next { + color:gray; + font-size:1.5em; + line-height:2em; +} +#body .inner .bottom-links .prev { + float:left; +} +#body .inner .bottom-links .next { + float:right; +}