Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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(
                    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

 
discard

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.