• 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)
  • Hi, did you try to enable the custom post type from the screen options (top right) in your appearance>menus ?

    Thread Starter imanewbe

    (@imanewbe)

    Its not a custom post type. Its just a custom type i have added, gallery. I have created this new type that isn’t a custom post type. It isn’t a wordpress post or page. So the system doesn’t know about it.

    It shows up in the left list and i can add to the menu from it with no trouble. Its just the items added from there come up with it being a custom link not the gallery.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Add Custom Type to Menu Page’ is closed to new replies.