• Resolved Sean

    (@aristophanes)


    Is there a way to number posts when on the category/arhive page? I have attempted using ordered lists, but I’m unsure where to apply them and have used block-level elements to contain titles, content etc.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You may not want to use ordered list because you have less control of how you want the number to appear.

    You could just make your own counter.

    <?php $post_no = 1; ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <?php echo $post_no; // display as you like ?>
    // display post, etc

    <?php $post_no++; >
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>

    <?php endif; ?>

    Thread Starter Sean

    (@aristophanes)

    Thank you very much for your help.

    Will this work across pages? That is, will the first post on the next page end up being #1 again?

    Yes, it will

    Thread Starter Sean

    (@aristophanes)

    Ok thanks. I don’t suppose there’s a workaround? (other than showing all posts in the category on the one page – which for me might be actually be the best option…)

    You could do something like this

    $post_no = $counter + $posts_per_page * ($page - 1)

    Of course, you have to somehow get the values for the variables in that formula above

    Thread Starter Sean

    (@aristophanes)

    Thanks alphaoide:)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Post Serial Number within a Category’ is closed to new replies.