', ' → ', ''); else echo get_the_term_list(get_the_ID(), 'gallerycat', ' → ', ' → ', ''); ?> slug . '&posts_per_page=1000'; $wpq = new WP_Query($query); /* echo $image_id; echo $query; print_r($term); print_r($wpq->posts); */ if (count($wpq->posts)) { $count = count($wpq->posts); $num = 0; $next = 0; $prev = 0; $f = false; foreach ($wpq->posts as $p) { if ($f) { $next = $p->ID; break; } if ($p->ID == $image_id) $f = true; } //echo '
$next: '.$next .'
'; $f = false; for ($i = $count - 1; $i >=0; $i--) { if ($f) { $prev = $wpq->posts[$i]->ID; break; } if ($wpq->posts[$i]->ID == $image_id) { $f = true; $num = $i + 1; } } if (! $next) $next = $wpq->posts[0]->ID; if (! $prev) $prev = $wpq->posts[$count - 1]->ID; $res = array( 'count' => $count, 'num' => $num, 'prev' => $prev, 'next' => $next, 'term' => $term ); //print_r($res); return $res; } } }