How to set class to “current-page” on the currently viewed single post within a CPT
I figured it out. Before the declaration of $case_query, I declare the active page id, like so: $active_page = get_the_ID();. Then, in the while loop after the_post(); I add the following: $activeclass=””; if (get_the_ID() === $active_page) { $activeclass=”current-page”; } I also add the $activeclass to the .case-list-item div: <div class=”case-list-item <?php echo $activeclass; ?>”> Solved.