Why is the Page Template dropdown menu using the wrong file name?

This was driving me nuts, and I finally decided to search for where a page template’s value is stored in the database. This gave me my first clue, because I found single-sponsor.php, the name of one of the other template files I’m building.

I was confused as to why this could be the case, and looked at the HTML of the actual dropdown menu WordPress generated:

<select name="page_template" id="page_template">
  <option value="default">Default Template</option>
  <option value="page-custom.php">Custom Page Example</option>
  <option value="single-sponsor.php" selected="selected">Market Main Page</option>
</select>

Pretty clearly choosing single-sponsor.php.

Why would it be doing that?

Because I told it to.

I had copied the code from page-market.php into single-sponsor.php to start developing a new page template.

At the top of single-sponsor.php?

<?php
/*
 Template Name: Market Main Page
*/
?>

Right.

Stupid mistake. But I thought it was worth writing up, in case the same thing happens to someone else.

I changed the name before realizing that I didn’t want this file to show up in my template list, so I removed the code.

Foo.