Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $currentPost = (array)$post;
- unset($currentPost['ancestors']);
- $currentPost = (object)$currentPost;
- $args = array( 'category_name' => 'events',
- 'post_status' => 'publish',
- 'meta_key' => '_EventStartDate',
- 'orderby' => 'meta_value',
- 'order' => 'ASC',
- 'posts_per_page'=> '-1' );
- $query = new WP_Query( $args );
- $queryPosts = $query->posts;
- $postKey = array_search( $currentPost, $queryPosts );
- if ( $postKey > 0 ) {
- $prevTitle = $queryPosts[ $postKey-1 ]->post_title;
- $prevLink = site_url().'/?p='.$queryPosts[ $postKey-1 ]->ID;
- }
- if ( $postKey < count( $queryPosts ) ) {
- $nextTitle = $queryPosts[ $postKey+1 ]->post_title;
- $nextLink = site_url().'/?p='.$queryPosts[ $postKey+1 ]->ID;
- } ?>
- <div class="tec-nav" id="tec-nav-below"><?php /* Use the same nav id and class style as found in list.php */ ?>
- <?php if ( !empty($prevTitle) ) {
- echo ('<div class="tec-nav-previous alignleft"><a href="'.$prevLink.'">« '.$prevTitle.'</a></div>'); }
- if ( !empty($nextTitle) ) {
- echo ('<div class="tec-nav-next alignright"><a href="'.$nextLink.'">'.$nextTitle.' »</a></div>'); }
- ?>
- <div style="clear: both;"></div>
- </div><!-- #tec-nav-below -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement