This WordPress snippet modifies the default output of wp_dropdown_pages() to display page options in the format:
{Page Title} - {slug} ({ID})
Instead of the default page title, each option in the dropdown will now include the page’s slug and ID for better clarity. This is useful for administrators working with multiple pages that might have similar titles.
Simply add this snippet to your theme’s functions.php or a custom plugin, and it will automatically apply to all wp_dropdown_pages() calls on your site.
<option value="1">Home - home (1)</option>
<option value="2">About Us - about-us (2)</option>
<option value="3">Contact - contact (3)</option>
I hope it helps with those frustrating dropdown fields with identical labels!