This topic has 8 replies, 3 voices, and was last updated 9 years by Abe.

  • Author
  • #26449
     sharmstr
    Moderator

    I know this out of the normal support scope, but can you tell me how the kleo specific meta boxes are added to the posts/page admin section? What I’m trying to figure out is how to get them to come up in a custom post type. Does kleo do a check to see if its a custom post type and then not display them?

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

    #26450
     sharmstr
    Moderator

    It just figures that 5 minutes after I posted this question, I figured it out. For anyone else wanting to do this.

    In /kleo/lib/metaboxes.php add your custom post type to the ‘pages’ key in the $meta_boxes array starting on line 19.

    Kleo team: How can I do this so its upgrade safe?

    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

    #27315
     Catalin
    Moderator

    you can make a copy of the file keeping the same structure in your child theme folder and make the modifications there.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #27329
     sharmstr
    Moderator

    I tried that and it didnt work. That’s why I asked. I copied /kleo/lib/metaboxes.php to /kleo-child/lib/metaboxes.php.

    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

    #27689
     sharmstr
    Moderator

    Any ideas?

    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

    #28801
     Abe
    Keymaster

    Hi, That won’t work since overriding is only available for page templates.
    You can do something like in your child theme functions:

    add_filter( 'kleo_meta_boxes', 'kleo_my_metaboxes' );
    function kleo_my_metaboxes( array $meta_boxes ) {
    
    	// Start with an underscore to hide fields from custom fields list
    	$prefix = '_kleo_';
    	
    	$meta_boxes[] = array(
    		'id'         => 'general_settings',
    		'title'      => 'Theme General settings',
    		'pages'      => array( 'custom_post_name' ), // Post type
    		'context'    => 'normal',
    		'priority'   => 'default',
    		'show_names' => true, // Show field names on the left
    		'fields'     => array(
    			array(
    				'name' => 'Media',
    				'desc' => '',
    				'id'   => 'kleomedia',
    				'type' => 'tab'
    			),
    			array(
    				'name' => 'Slider',
    				'desc' => 'Used when you select the Gallery format. Upload an image or enter an URL.',
    				'id'   => $prefix . 'slider',
    				'type' => 'file_repeat',
    				'allow' => 'url'
    			),
    			array(
    				'name' => 'Video oEmbed URL',
    				'desc' => 'Used when you select Video format. Enter a Youtube, Vimeo, Soundcloud, etc URL. See supported services at http://codex.wordpress.org/Embeds.',
    				'id'   => $prefix . 'embed',
    				'type' => 'oembed',
    			),
    				
    			array(
    				'name' => 'Video Self hosted(mp4)',
    				'desc' => 'Used when you select Video format. Upload your MP4 video file. Setting a self hosted video will ignore Video oEmbed above.',
    				'id'   => $prefix . 'video_mp4',
    				'type' => 'file',
    			),
    			array(
    				'name' => 'Video Self hosted(ogv)',
    				'desc' => 'Used when you select Video format. Upload your OGV video file.',
    				'id'   => $prefix . 'video_ogv',
    				'type' => 'file',
    			),
    			array(
    				'name' => 'Video Self hosted(webm)',
    				'desc' => 'Used when you select Video format. Upload your WEBM video file.',
    				'id'   => $prefix . 'video_webm',
    				'type' => 'file',
    			),
    				
    			array(
    				'name' => 'Audio',
    				'desc' => 'Used when you select Audio format. Upload your audio file',
    				'id'   => $prefix . 'audio',
    				'type' => 'file',
    			),
    			array(
    				'name' => 'Display settings',
    				'desc' => '',
    				'id'   => 'kleodisplay',
    				'type' => 'tab'
    			),
    			array(
    				'name' => 'Centered text',
    				'desc' => 'Check to have centered text on this page',
    				'id'   => $prefix . 'centered_text',
    				'type' => 'checkbox',
    				'value' => '1'
    			),
    			array(
    				'name' => 'Top bar status',
    				'desc' => 'Enable/disable site top bar',
    				'id'   => $prefix . 'topbar_status',
    				'type' => 'select',
    				'options' => array(
    						array('value' => '', 'name' => 'Default'),
    						array('value' => '1', 'name' => 'Visible'),
    						array('value' => '0', 'name' => 'Hidden')
    					),
    				'value' => ''
    			),
    			array(
    				'name' => 'Hide Header',
    				'desc' => 'Check to hide whole header area',
    				'id'   => $prefix . 'hide_header',
    				'type' => 'checkbox',
    				'value' => '1'
    			),
    			array(
    				'name' => 'Hide Footer',
    				'desc' => 'Check to hide whole footer area',
    				'id'   => $prefix . 'hide_footer',
    				'type' => 'checkbox',
    				'value' => '1'
    			),
    			array(
    				'name' => 'Hide Socket area',
    				'desc' => 'Check to hide the area after footer that contains copyright info.',
    				'id'   => $prefix . 'hide_socket',
    				'type' => 'checkbox',
    				'value' => '1'
    			),
    			array(
    				'name' => 'Custom Logo',
    				'desc' => 'Use a custom logo for this page only',
    				'id'   => $prefix . 'logo',
    				'type' => 'file',
    			),
    			array(
    				'name' => 'Custom Logo Retina',
    				'desc' => 'Use a custom retina logo for this page only',
    				'id'   => $prefix . 'logo_retina',
    				'type' => 'file',
    			),
    			array(
    				'name' => 'Transparent Main menu',
    				'desc' => 'Check to have Main menu background transparent.',
    				'id'   => $prefix . 'transparent_menu',
    				'type' => 'checkbox',
    				'value' => '1'
    			),
    				
    				
    			array(
    				'name' => 'Title section',
    				'desc' => '',
    				'id'   => 'kleoheader',
    				'type' => 'tab'
    			),
    			array(
    				'name' => 'Hide the title',
    				'desc' => 'Check to hide the title when displaying the post/page',
    				'id'   => $prefix . 'title_checkbox',
    				'type' => 'checkbox',
    				'value' => '1'
    			),
    			array(
    				'name' => 'Breadcrumb',
    				'desc' => '',
    				'id'   => $prefix . 'hide_breadcrumb',
    				'type' => 'select',
    				'options' => array(
    						array('value' => '', 'name' => 'Default'),
    						array('value' => '0', 'name' => 'Visible'),
    						array('value' => '1', 'name' => 'Hidden')
    					),
    				'value' => ''
    			),
    				
    			array(
    				'name' => 'Hide information',
    				'desc' => 'Check to hide contact info in title section',
    				'id'   => $prefix . 'hide_info',
    				'type' => 'checkbox',
    				'value' => '1'
    			)
    		)
    	);
    	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

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #28805
     sharmstr
    Moderator

    Brilliant. Thank you.

    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

    #28806
     sharmstr
    Moderator

    @abe. This works great. At first I was thinking that it sucked to have to use all of that code just to add a custom post type, but what I realized is now I have complete control over what settings can be changed. My site will have hundreds of authors and I want to give them the ability to add media to their posts, but not change any of the page formatting. Plus I can remove the ‘upload/self hosted’ fields so they have to use youtube and vimeo videos. Thank you! 🙂

    COPY CODE
    
    
    add_filter( 'kleo_meta_boxes', 'kleo_my_metaboxes' );
    function kleo_my_metaboxes( array $meta_boxes ) {
     
        // Start with an underscore to hide fields from custom fields list
        $prefix = '_kleo_';
        
        $meta_boxes[] = array(
            'id'         => 'general_settings',
            'title'      => 'Story Media',
            'pages'      => array( 'fiction' ), // Post type
            'context'    => 'normal',
            'priority'   => 'default',
            'show_names' => true, // Show field names on the left
            'fields'     => array(
               
                array(
                    'name' => 'Slider',
                    'desc' => 'Used when you select the Gallery format. Upload an image or enter an URL.',
                    'id'   => $prefix . 'slider',
                    'type' => 'file_repeat',
                    'allow' => 'url'
                ),
                array(
                    'name' => 'Media oEmbed URL',
                    'desc' => 'Used when you select Video format. Enter a Youtube, Vimeo, Soundcloud, etc URL. See supported services at <a target="_blank" href="http://codex.wordpress.org/Embeds" rel="nofollow">http://codex.wordpress.org/Embeds</a>.',
                    'id'   => $prefix . 'embed',
                    'type' => 'oembed',
                )
            )
        );
        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

    #28809
     Abe
    Keymaster

    Great. I am glad I could help 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

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

The topic ‘Add kleo meta box to custom post type’ is closed to new replies.

Log in with your credentials

Forgot your details?