Add Custom Type to Menu Page
-
I have added a custom link section to the menus page by doing the following:
add_meta_box('gallery_meta_box', __( 'Galleries' ), array(__CLASS__, 'render_add_galleries_nav_menu'), 'nav-menus', 'side', 'default' ); public static function render_add_galleries_nav_menu(){ global $daybreak; $galleries = $daybreak->get_galleries( 999 ); ?> <div id="gallery-archive" class="posttypediv"> <ul class="gallery-tabs add-menu-item-tabs"> <li class="tabs"><?php _e( 'Galleries' ); ?></li> </ul> <div class="tabs-panel tabs-panel-active"> <ul class="categorychecklist form-no-clear"> <?php foreach ($galleries as $key => $gallery ): ?> <li> <label class="menu-item-title"><input type="checkbox" class="menu-item-checkbox" name="menu-item[-<?php echo $key; ?>][menu-item-object-id]" value="<?php echo $post_type->name; ?>"> <?php echo $gallery->title; ?></label> <input type="hidden" class="menu-item-title" name="menu-item[-<?php echo $key; ?>][menu-item-title]" value="<?php echo $gallery->title; ?>"> <input type="hidden" class="menu-item-url" name="menu-item[-<?php echo $key; ?>][menu-item-url]" value="<?php echo $daybreak->get_gallery_url($gallery); ?>"> <input type="hidden" value="custom" name="menu-item[-<?php echo $key; ?>][menu-item-type]"> </li> <?php endforeach; ?> </ul> </div> <p class="button-controls"> <span class="add-to-menu"> <input type="submit" class="button-secondary submit-add-to-menu right" value="Add to Menu" name="add-gallery-menu-item" id="submit-gallery-archive"> <span class="spinner"></span> </span> </p> </div> <?php }This works fine. I can add these items to the menu but when I do they are added as a “Custom Link” I want to add them as a “Gallery”. If I change the menu-item-type to ‘gallery’ then they do not get added to the menu and the page throws a JS error.
Is there some way to do this?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Add Custom Type to Menu Page’ is closed to new replies.