Move Stand With Israel Under Partners – Direct DB

Move Stand With Israel Under Partners – Direct DB Update

PHP snippet using direct database queries to move the Stand With Israel menu item under Partners.

<?php
// Move Stand With Israel under Partners menu - Direct approach
if (!wp_next_scheduled('move_stand_israel_menu')) {
    wp_schedule_single_event(time(), 'move_stand_israel_menu');
}

add_action('move_stand_israel_menu', function() {
    global $wpdb;
    
    // Find Stand With Israel menu item (it's linked to page 52046)
    $stand_israel_item = $wpdb->get_row(
        $wpdb->prepare(
            "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'nav_menu_item' AND post_parent = %d",
            52046
        )
    );
    
    // Find Partners menu item (it's linked to page with title 'Partners')
    $partners_page = $wpdb->get_row(
        "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'page' AND post_title = 'Partners' LIMIT 1"
    );
    
    if ($partners_page) {
        $partners_item = $wpdb->get_row(
            $wpdb->prepare(
                "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'nav_menu_item' AND post_parent = %d",
                $partners_page->ID
            )
        );
        
        if ($partners_item && $stand_israel_item) {
            // Update the parent of Stand With Israel menu item
            $wpdb->update(
                $wpdb->posts,
                array('post_parent' => $partners_item->ID),
                array('ID' => $stand_israel_item->ID)
            );
            
            // Also update the menu item parent meta
            update_post_meta($stand_israel_item->ID, '_menu_item_menu_item_parent', $partners_item->ID);
            
            error_log('✓ Stand With Israel moved under Partners menu');
        }
    }
});
?>
Facebook
Twitter
LinkedIn

Subscribe to our YouTube channel to discover more about us.