Add class to query_posts loop

I would like to be able to add a class to posts from a query (which would appear under the element, however I have only figured out how to wrap the posts with which doubles up the element. I can’t see a parameter for query_posts() to do this. Is it possible to use post_class() somehow in this loop?

$args = unserialize( stripslashes( $_POST['query'] ) );
$args['paged'] = $_POST['page'] + 1;
$args['post_status'] = 'publish';
query_posts( $args);

    if( have_posts()) : 
    ?> <article class="newcomment"><?php

        while( have_posts() ): the_post();
            get_template_part( 'loop-templates/content', get_post_format() );


I just want to have each post from this loop have a class added called “newcomment” so that I can manipulate via javascript. Any help greatly appreciated, thanks for looking!

Read more here: Add class to query_posts loop

Leave a Reply

Your email address will not be published. Required fields are marked *