As the title states, I want to output the class of the category onto the looped queries.
At the moments I could use post class but I want to only add the one class and already have a set number of classes. For me this is all about getting 1 or more values from the array and echo’ing them out as a string into my loop template.
array(7) {
[0]=> string(8) "post-170"
[1]=> string(4) "post"
[2]=> string(9) "type-post"
[3]=> string(14) "status-publish"
[4]=> string(15) "format-standard"
[5]=> string(6) "hentry"
[6]=> string(22) "category-uncategorised"
}
Currently
<?php $counter = 0;
$query = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => '50'
));
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
// Update Counter
$counter++;
<div class="newsfeed__blk <?php echo 'is--' . $counter; ?> col-md-4 col-sm-6 col-xs-12 <?php get_post_class([6]); ?>">...</div>
<?php endwhile; endif; wp_reset_query(); ?>
End Result
I want a newsfeed with testimonials. In wordpress I will assign a category to the post. When the page is rendered the query will add a custom class to differentiate the DOM element for my custom SCSS styles.