Created
October 22, 2010 21:38
-
-
Save jbynum/641425 to your computer and use it in GitHub Desktop.
how to paginate custom post type in wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$docs = get_posts('numberposts=-1&post_type=page&post_parent=36&orderby=title&order=ASC'); | |
$faculty = array(); | |
foreach ($docs as $doc) { | |
array_push($faculty, $doc->ID); | |
} | |
$currentElement = array_search($post->ID, $faculty); | |
$next = isset( $faculty[$currentElement+1] ) ? $faculty[$currentElement+1] : null; | |
$prev = isset($faculty[$currentElement-1]) ? $faculty[$currentElement-1] : null; | |
if ( !is_null($prev) ) { | |
$prevDoc = query_posts( array('page_id' => $prev) ); | |
$prevDocHref = '<a href="/faculty/' . $prevDoc[0]->post_name .'" class="docArrows"><img src="'. get_bloginfo('template_directory') .'/images/prevDocArrow.jpg" alt="Previous" /></a>'; | |
} | |
if ( !is_null($next) ) { | |
$nextDoc = query_posts( array('page_id' => $next) ); | |
$nextDocHref = '<a href="/faculty/' . $nextDoc[0]->post_name .'" class="docArrows"><img src="'. get_bloginfo('template_directory') .'/images/nextDocArrow.jpg" alt="Next" /></a>'; | |
} | |
?> | |
<?= $prevDocHref ?> | |
<a href="http://cancergrace.net/faculty/"> | |
<img src="<?php bloginfo('template_directory'); ?>/images/meet.jpg" alt="" /> | |
</a> | |
<?= $nextDocHref ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment