• Hello all!

    As my custom taxonomies are essential for my articles, I would like to move them from side menu to my custom meta box.

    Here is (simplified) code I’m using:

    // Remove taxonomy meta_boxes from side
    function tax_remove_from_side() {
        remove_meta_box('tagsdiv-skill', 'web', 'side' );
    }
    add_action('my_custom_hook', 'tax_remove_from_side');
    
    // Add taxonomy meta_boxes to my custom meta_box
    function tax_add_to_box() {
    	global $post;
    	$tax = get_object_taxonomies(get_post_type());
    	echo '<div id="meta_tax">';
    	foreach ($tax as $t) {
    		$t_o = get_taxonomy($t); ?>
    		<div class="cell item">';
    			<strong><?php echo $t_o->labels->name; ?></strong>
    			<?php if ($t_o->hierarchical) {
    				post_categories_meta_box($post, array('args' => array('taxonomy' => $t), 'title' => $t_o->labels->name));
    			} else {
    				post_tags_meta_box($post, array('args' => array('taxonomy' => $t), 'title' => $t_o->labels->name));
    			} ?>
    		</div>
    	}
    	echo '</div>';
    }
    add_action('my_custom_hook_for_metabox', 'tax_add_to_box');

    Does that make sense?

    My problem: If I remove all nonhierarchical taxonomies from sidemenu, link “Choose from the most used tags” and other JS functionality for nonhierarchical (tag-like)taxonomies stops working. Oddly enough, hierarchical taxonomies (category-like) JS functionality works smoothly.

    My current ugly solution: Custom taxonomy called “Very nasty hack” that is left on sidebar (so JS functionality remains) but is never included to my custom meta_box. 🙂 Very nasty, but works.

    ///

    After some digging in core files, I think I’ve found relevant pieces of code for the problem: file wp-includes/js/post.js, lines 19-179. Especially variable Disabled, defined under function quickClicks on line 58.

    I see, that the variable works in a few conditionals later, but to be honest, that is as far as my understanding of the situation goes. 🙂

    ///

    Any idea how to enable JS functionality for nonhierarchical meta_boxes even if they don’t appear at the side menu PROPERLY? THANKS IN ADVANCE!

Viewing 1 replies (of 1 total)
  • Thread Starter Cibulka

    (@cibulka)

    Okay, here goes an answer at WP StackExchange: Can custom taxonomies be displayed inside of a custom meta box?

    Finally, note that in the case of “Keywords” or any other Tag-like taxonomy, this will not be enough. The tags metabox functionality is achieved via JS, which depends on selectors that are not created by the function above. In my case this was solved by adding the class “inside” to the keywords div, and by adding these lines to a separate JS file:

    $('.keywords').each(function(){
        tagBox.init();
        return false;
    });

    For some reason, I’m still not able to get it working though …

Viewing 1 replies (of 1 total)
  • The topic ‘post_tags_meta_box() – Javascript functionality no longer works’ is closed to new replies.