Print Current Post Index number within Loop

Actually I want to assign ID’s as per post index !

Here’s your code that I modified.

<?php

global $wp_query;

$posts = $woo_options['woo_latest_entries'];
query_posts('post_type=post&category_name=company');

if ( have_posts() ) : while ( have_posts() ) : the_post();  $count++;
    $index = $wp_query->current_post + 1;

?>
    <div id="my_post_<?php echo $index; ?>">

        <!-- Post Content Goes Here -->

    </div>

<?php endwhile; endif; ?>

Leave a Comment