This topic has 2 replies, 2 voices, and was last updated 8 years by playism.

  • Author
  • #75016
     playism
    Participant

    Hello,

    is there a way to enable “main menu options” box for product type, for some product pages, we want to display custom menus.

    Thanks

    #75034
     sharmstr
    Moderator

    Put this in your child theme’s functions.php file

    COPY CODE
    
    add_filter( 'kleo_meta_boxes', 'custom_kleo_metaboxes' );
    /**
     * Define the metabox and field configurations.
     *
     * @param  array $meta_boxes
     * @return array
     */
    function custom_kleo_metaboxes( array $meta_boxes )
    {
    
        // Start with an underscore to hide fields from custom fields list
        $prefix = '_kleo_';
        //Custom menu
        $kleo_menus = wp_get_nav_menus();
        $menu_options = array();
        $menu_options[] = array('value' => 'default', 'name' => 'Site default');
        foreach ($kleo_menus as $menu) {
            $menu_options[] = array('value' => $menu->slug, 'name' => $menu->name);
        }
    
        $meta_boxes[] = array(
            'id' => 'page_menu',
            'title' => 'Main menu options',
            'pages' => array('product'), // Post type
            'context' => 'side',
            'priority' => 'default',
            'show_names' => true, // Show field names on the left
            'fields' => array(
    
                array(
                    'name' => 'Custom menu',
                    'desc' => '',
                    'id' => $prefix . 'page_menu',
                    'type' => 'select',
                    'options' => $menu_options,
                    'value' => 'default'
                ),
                array(
                    'name' => 'Hide Shop',
                    'desc' => 'Check to hide the Shop icon in the main menu',
                    'id' => $prefix . 'hide_shop_icon',
                    'type' => 'checkbox',
                    'value' => '1'
                ),
                array(
                    'name' => 'Hide Search',
                    'desc' => 'Check to hide the Search icon in the main menu',
                    'id' => $prefix . 'hide_search_icon',
                    'type' => 'checkbox',
                    'value' => '1'
                ),
    
            ),
        );
    
    
        // Add other metaboxes as needed
    
        return $meta_boxes;
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #75714
     playism
    Participant

    works great. thanks.

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?