How do I use $wp_query->current_post with get_template_part? I'm trying to add post classes (first/last/even/odd) to custom loops

... but $wp_query->current_post and the like don't work when I use get_template_part to pull in content.php files as modeled by themes like twentynineteen. The variables don't carry over I guess?

Is there a way to add custom post classes to posts created by a custom query while also using get_template_part? Thank You.

Topic wp-query post-class Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.