Take your website
To the next level
Discover our newly launched customization services and elevate your web projects to new heights.
Delegate tasks, save time, and unlock the power of professional WordPress outsourcing.

Okay
  Public Ticket #2411099
MetaBox in Custom post types
Closed

Comments

  • Hugo started the conversation

    Hi.

    After diggin a lot, I found this code in public tickets, to add the thegem metabox in custom post types

    function thegem_add_page_settings_boxes()
    {
        $post_types = array('post', 'page', 'thegem_pf_item', 'thegem_news', 'product', 'custom_post_type_1', 'custom_post_type_2');
        foreach ($post_types as $post_type) {
            add_meta_box('thegem_page_title', esc_html__('Page Title', 'thegem'), 'thegem_page_title_settings_box', $post_type, 'normal', 'high');
            add_meta_box('thegem_page_header', esc_html__('Page Header', 'thegem'), 'thegem_page_header_settings_box', $post_type, 'normal', 'high');
            add_meta_box('thegem_page_footer', esc_html__('Page Footer', 'thegem'), 'thegem_page_footer_settings_box', $post_type, 'normal', 'high');
            add_meta_box('thegem_page_sidebar', esc_html__('Page Sidebar', 'thegem'), 'thegem_page_sidebar_settings_box', $post_type, 'normal', 'high');
            if (thegem_is_plugin_active('thegem-elements/thegem-elements.php')) {
                add_meta_box('thegem_page_slideshow', esc_html__('Page Slideshow', 'thegem'), 'thegem_page_slideshow_settings_box', $post_type, 'normal', 'high');
            }
            add_meta_box('thegem_page_effects', esc_html__('Additional Options', 'thegem'), 'thegem_page_effects_settings_box', $post_type, 'normal', 'high');
            add_meta_box('thegem_page_preloader', esc_html__('Page Preloader', 'thegem'), 'thegem_page_preloader_settings_box', $post_type, 'normal', 'high');
        }
        add_meta_box('thegem_product_size_guide', esc_html__('Size Guide', 'thegem'), 'thegem_product_size_guide_settings_box', 'product', 'normal', 'high');
        add_meta_box('thegem_post_item_settings', esc_html__('Blog Post Settings', 'thegem'), 'thegem_post_item_settings_box', 'post', 'normal', 'high');
    }
    add_action('add_meta_boxes', 'thegem_add_page_settings_boxes');

    But this doesn't have Page Widgets metabox and the preload metabox return an error  "function 'thegem_page_preloader_settings_box' not found or invalid function name"

    The same if I try to add pw_widgets

    Can you help me updating this code coding by you?

    Thanks

  •  7,092
    Oliver replied

    Hi,

    pls. provide wp-admin, FTP access and add few screenshots to describe the issue in details.

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  • Hugo replied

    The situation is simple.

    I create two new custom_post_types, CPT1 and CPT2, but they miss the metabox from your theme.

    I need the metaboxes (Attachment 1) in the end of my "New/edit" Custom Posts Types.

    So, after diggin how can i add that metaboxes to the new post types, I found that code in one of your public tickets from this theme.

    https://codexthemes.ticksy.com/ticket/2345824/

    Seems like that code is a litle outdated, because doesn't have the "Page Widgets" metabox and have "Page Preloader" wich not existed before, show me an error.

    My only question, how can I add that metaboxes to my new custom post types?

    Tks

  •  7,092
    Oliver replied

    Hi,

    Add this code to the functions.php of the child theme:

    function thegem_add_page_settings_boxes()
        {
            $post_types = array('post', 'page', 'thegem_pf_item', 'thegem_news', 'product');
            foreach ($post_types as $post_type) {
                add_meta_box('thegem_page_title', esc_html__('Page Title', 'thegem'), 'thegem_page_title_settings_box', $post_type, 'normal', 'high');
                add_meta_box('thegem_page_header', esc_html__('Page Header', 'thegem'), 'thegem_page_header_settings_box', $post_type, 'normal', 'high');
                add_meta_box('thegem_page_footer', esc_html__('Page Footer', 'thegem'), 'thegem_page_footer_settings_box', $post_type, 'normal', 'high');
                add_meta_box('thegem_page_sidebar', esc_html__('Page Sidebar', 'thegem'), 'thegem_page_sidebar_settings_box', $post_type, 'normal', 'high');
                if (thegem_is_plugin_active('thegem-elements/thegem-elements.php')) {
                    add_meta_box('thegem_page_slideshow', esc_html__('Page Slideshow', 'thegem'), 'thegem_page_slideshow_settings_box', $post_type, 'normal', 'high');
                }
                add_meta_box('thegem_page_effects', esc_html__('Additional Options', 'thegem'), 'thegem_page_effects_settings_box', $post_type, 'normal', 'high');
                add_meta_box('thegem_one_page', esc_html__('One Page Options', 'thegem'), 'thegem_one_page_settings_box', $post_type, 'normal', 'high');
            }
            add_meta_box('thegem_product_size_guide', esc_html__('Size Guide', 'thegem'), 'thegem_product_size_guide_settings_box', 'product', 'normal', 'high');
            add_meta_box('thegem_post_item_settings', esc_html__('Blog Post Settings', 'thegem'), 'thegem_post_item_settings_box', 'post', 'normal', 'high');
        }
        add_action('add_meta_boxes', 'thegem_add_page_settings_boxes');
    

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •  7,092
    Oliver replied

    Here you need to add your post type name:

            $post_types = array('post', 'page', 'thegem_pf_item', 'thegem_news', 'product');
    


    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver