Hide Drafts in Menus source code
By Room 34 Creative Services, LLC, on WordPress.org since 2016. 1,000+ active installs.
If you unpublish a page or post, it still appears in your custom menus. Below is its source code for every one of its 16 releases, what changed in the latest one, and how often it ships.
What changed in 1.6.0.1
Released May 18, 2026, 27 minutes after 1.6.0- Refactored r34hdm_get_unpublished_items() function to retrieve non-published posts using get_posts() function instead of a direct SQL query. (Note: The previous direct SQL query allowed us to limit the returned list to posts that were already confirmed to be in the menu; however, this method allows for a single query per page rather than one for each menu, which may offset any performance impact.)
- Miscellaneous tweaks to pass Plugin Check tests.
- Bumped “tested up to” to 7.0.
- Updated copyright year.
2 files changed since 1.6.0: 2 modified, 0 added, 0 removed.
- hide-drafts-in-menus.php modified, -92 bytes
- readme.txt modified, +4 bytes
Release history
16 releases since November 2016- 1.6.0.1 May 18, 2026 Refactored r34hdm_get_unpublished_items() function to retrieve non-published posts using get_posts() function instead of a direct SQL query. (Note: The previous direct SQL query allowed us to limit the returned list to posts that were already confirmed to be in the menu; however, this method allows for a single query per page rather than one for each menu, which may offset any performance impact.)
- 1.6.0 May 18, 2026
- 1.5.1.1 May 18, 2026
- 1.5.1 May 14, 2024 Fixed an issue that would cause categories to be hidden. Added a check to ensure that the logic for hiding menu items only applies to items that are a post type (e.g. post, page, custom post type), not taxonomies or other types of objects.
- 1.5.0 May 1, 2024 Changed SQL query to simply look for all posts that are not set to a status of publish, rather than the previous check for a few specific status values.