Created
July 17, 2014 13:58
-
-
Save ideag/6c94a26eb52fbd4f40c0 to your computer and use it in GitHub Desktop.
Remove WordPress nav menu item if asociated page is trashed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'publish_to_trash', 'klausk_delete_menu_item' ); | |
function klausk_delete_menu_item($post) { | |
// tik puslapiams | |
if( $post->post_type !== 'page' ) | |
return; | |
// jei tema nepalaiko meniu - nieko daryti nereikia | |
if ( ! current_theme_supports( 'menus' ) ) { return; } | |
// trinamas meniu punktas | |
_wp_delete_post_menu_item($post->ID); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment