You could use post_class
within the loop.
<?php post_class( 'myclass-here'); ?>
This will add the necessary HTML class=""
and WP defaults classes plus your new myclass-here
class
You could then use counters within the loop to add a unique suffix to your post class
// Outside the loop initialize your counter
$counter = 1;
.
// Then in the loop
<?php post_class( 'myclass-here-' . $counter ); $counter++; ?>
EDIT
Ok taking into consideration the new information in your question, the way to go is to set a query var and that variable would now be available in your template part.
index.php
Here you would set your query var just before calling get_template_part()
and you would increment it just after. You still have to initialize outside the loop the $counter
of course. it would look something like this
<?php set_query_var( 'counter', $counter ); ?>
<?php get_template_part( 'content', get_post_format() ); $counter++; ?>
then in your content.php file, you would just have to call your variable $counter
<article id="post-<?php the_ID(); ?>" <?php post_class( 'inline-post-' . $counter ); ?>>
don’t increment your $counter
in your content.php file and don’t include locate_template()
either