Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

imanewbe on "Add Custom Type to Menu Page"

$
0
0

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 all articles
Browse latest Browse all 8245

Trending Articles