WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have custom post type works with custom taxonomy work_category I want to build such pagination while viewing single.php

previous 2/25 next

[link to previous post in custom tax] [current post number]/[all post number from custom tax] [next post in custom tax]

Currently i can't get current post number

share|improve this question
up vote 1 down vote accepted

I've solved it

For previous/next use Ambrosite Next/Previous Post Link Plus

To get current/all use following code inside the loop

        $query = new WP_Query( array(
            'post_type' => 'works',
            'post_status' => 'publish',
            'posts_per_page' => '-1',
            'tax_query' => array(
                        'taxonomy' => 'work_category',
                        'field' => 'slug',
                        'terms' => 'design'
            'order' => 'ASC'
        ) );
        $all = $query->post_count;
        foreach( $query->posts as $key => $p )
            if( $post->ID == $p->ID ) $current = $key + 1;

        echo $current.'/'.$all;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.