• lkistenkas

    (@lkistenkas)


    First of all thank you for this plugin, it almost did exactly what I needed.

    The limitation I had was that I could only select pages as menu items, but I have a custom menu with custom post types as menu items which have custom post types and pages as submenu items. So it was important for me to select a custom post type as parent menu item.

    I made some simple but little ugly changes to the view.php, but it works for me:

    Change 1: Get menu items instead of pages:

    
                    //$pages = get_posts( array( 'numberposts' => -1, 'post_type' => 'page', 'suppress_filters' => false ) );
                    $menu_locations = get_nav_menu_locations();
                    $menu = wp_get_nav_menu_object( $menu_locations['primary_navigation'] );
                    $menu_items = wp_get_nav_menu_items( $menu->term_id );
    
    

    Change 2: Loop menu items instead of pages, changed $page->ID to $menu_item->object_id:

    
                                <?php foreach($menu_items as $menu_item):?>
                                    <option value="<?php echo $menu_item->object_id;?>"<?php if(!empty($cmicptData->{$postType->name}) && $cmicptData->{$postType->name} == $menu_item->object_id):?> selected="selected"<?php endif;?>><?php echo $menu_item->title;?></option>
                                <?php endforeach;?>	
    
    

    Perhaps this will help someone else as well, or perhaps it will help you for a better integrated solution in the plugin (I now just made a fork of your plugin for my specific project).

  • The topic ‘Select all sort of menu items from primary_navigation’ is closed to new replies.