WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] I moved a meta_box in the admin via jQuery but now it won't open (3 posts)

  1. Glenn Ansley
    Member
    Posted 6 years ago #

    Hi,
    I placed the following code in the admin header via admin_head action so that I could move some divs around. In the code below, I moved the excerpt div, but the goal is to move a custom box added via the add_meta_box action.

    Anyway, it relocates fine, but the open/close functionality no longer works. I was wondering if anyone could help me figure out why it breaks and if it would work for me to just recreate the effect somehow. Thanks!

    The following code will move the post excerpt box above the tags box in the write post screen if called via add_action('admin_head','yourfunction').

    <script type="text/javascript">
    			jQuery(document).ready(function(){
    					jQuery("#postexcerpt").addClass("wptemplate");
    					jQuery("#tagsdiv").before(jQuery("#postexcerpt").clone().removeClass("wptemplate"));
    					jQuery(".wptemplate").remove();
    			})
    		</script>
  2. Glenn Ansley
    Member
    Posted 6 years ago #

    I added the following script to get the box to open/close again. there's probably a better way to hook into the existing JS that does this.

    jQuery('#postexcerpt h3').click( function() {
    	jQuery(jQuery(this).parent().get(0)).toggleClass('closed');
    } );
  3. jaiunblog
    Member
    Posted 5 years ago #

    thank you for this self-resolved !

Topic Closed

This topic has been closed to new replies.

About this Topic