This code works just fine on individual posts. But on the archive page for the post type, one of the individual posts is getting the current-menu-item class even though it is not the current page. Image of the archive page attached; see "District 17A" in the sidebar, where this loop output is displayed.
$current_page will return the ID of the current page.
Archives are no pages, they have no ID in that sense.
Now, however that single item receives the wrong class, I can see all the others do not.
Hence this is an issue with the single post.
If you re-save or even re-create that post, is the issue persisting?
Then we need to know how you create the archive, what ID you expect, and which you get instead.
To do this you can simply compare the outputs of [wpv-post-id], [wpv-post-id id='$current_page'] in the related archive, before you add a condition by them.
You will immediately recognize that your archive is not a page and most likely you receive the wrong value from [wpv-post-id id='$current_page'].
I don't think this will work like this.
Rather probably you need to compare the current archive term or type with the title or slug of your posts.
So this (I believe) is totally independent of the issue I am having with District 17A receiving "current-menu-item" when viewing the Archive page.
I re-saved the District 17A post but the issue persisted.
When I view any of the individual district posts, only the post being displayed receives the current-menu-item class, including District 17A.
I have opted to work around the issue. My new loop item template:
<li class="menu-item [wpv-conditional if="( '[wpv-archive-title]' ne 'Districts' )"][wpv-conditional if=([wpv-post-id]=[wpv-post-id id='$current_page'])]current-menu-item[/wpv-conditional][/wpv-conditional]">[wpv-post-link]</li>
Since the problem was only happening on the Archive page, I'll just test to make sure we're not on an archive page, before adding current-menu-item to any loop item.
As Beda mention the [wpv-post-id id='$current_page'] won't work as intended since its on an archive page. You will need to use something else to determine the page. I see that you are using the [wpv-archive-title] this can be used for archives.
Please let me know if your final testing works and if any assistance is needed.
My workaround seems to be fine. I'll detect the Archive page outside the loop, for "District Map" to get the proper current-menu-item class only on the archive page. And since the District posts are properly getting the current-menu-item class when viewing District posts, I'll just conditionally not perform that check on the archive page.