WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/07/2016 04:49:19 PM (4 years ago)
Author:
swissspidy
Message:

Menus: Do not show trashed posts in nav menus.

Trashed posts cannot be accessed by site visitors and thus should not be visible on the front end. By marking menu items of trashed posts as invalid, they are excluded from the output.

Props solarissmoke, swissspidy.
Fixes #19038.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu.php

    r38369 r38744  
    745745                } else {
    746746                    $menu_item->type_label = $menu_item->object;
     747                    $menu_item->_invalid = true;
     748                }
     749
     750                if ( 'trash' === get_post_status( $menu_item->object_id ) ) {
    747751                    $menu_item->_invalid = true;
    748752                }
Note: See TracChangeset for help on using the changeset viewer.