• Hi,

    I’m trying to split the Categories meta box on the write post page into two meta boxes (showing each all sub-categories of a specific category).

    I tryed to add new meta boxes:

    add_meta_box( 'my_sectionid', __( 'Categories', 'my_textdomain' ), 'cat_box1_inner_custom_box', 'post', 'side' );

    and:

    function cat_box1_inner_custom_box() {
    	global $post, $categories;
    
      // Use nonce for verification
    
      echo '<input type="hidden" name="myplugin_noncename" id="myplugin_noncename" value="' .
        wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
    
      // The actual fields for data entry
    		$cats = wp_get_post_categories($post->ID); 
    
    ?>
    	<ul id="category-tabs">
    		<li class="tabs"><a href="#categories-events" tabindex="3"><?php _e( 'Event Categories' ); ?></a></li>
    		<li class="hide-if-no-js"><a href="#categories-loc" tabindex="3"><?php _e( 'Locations' ); ?></a></li>
    	</ul>
    
    	<div id="categories-loc" class="tabs-panel" style="display: none;">
    		<ul id="categorychecklist-loc" class="categorychecklist form-no-clear" >
    	<?php 		wp_category_checklist($post->ID, 39, $cats); ?>
    		</ul>
    	</div>
    
    	<div id="categories-events" class="tabs-panel">
    		<ul id="categorychecklist-events" class="list:category categorychecklist form-no-clear">
    	<?php
    		$cats = wp_get_post_categories($post->ID); 
    
    		wp_category_checklist($post->ID, 3, $cats); ?>
    		</ul>
    	</div>
    <?php
    } ?>

    How do I save the selected categories? Someone able to help?
    Thank you!

    (I’m aware that this code / CSS IDs gets “in the way” of the normal category meta box.)

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Removing category meta box & adding 2 sub-category meta boxes’ is closed to new replies.