Skip to content

Instantly share code, notes, and snippets.

@jbynum
jbynum / Paginate Custom Posts
Created October 22, 2010 21:38
how to paginate custom post type in wordpress
<?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) ) {