Auto close (hide) custom metabox / set default state

Hook into postbox_classes. postbox_classes is the function which will output the classes for the metabox. apply_filters( “postbox_classes_{$page}_{$id}”, $classes ) Your code could look like this: add_action( ‘add_meta_boxes’, ‘add_my_metabox’ ); function add_my_metabox() { $id = ‘my-metabox’; $title=”My Metabox”; $callback = ‘my_metabox_content’; $page=”post”; add_meta_box( $id, $title, $callback, $page ); add_filter( “postbox_classes_{$page}_{$id}”, ‘minify_my_metabox’ ); } function my_metabox_content() { … Read more

Re Order Editor to be after meta box [duplicate]

This will allow the post editor to be moved like the other sortable post boxes. function move_posteditor( $hook ) { if ( $hook == ‘post.php’ OR $hook == ‘post-new.php’ ) { wp_enqueue_script( ‘jquery’ ); add_action(‘admin_print_footer_scripts’, ‘move_posteditor_scripts’); } } add_action( ‘admin_enqueue_scripts’, ‘move_posteditor’, 10, 1 ); function move_posteditor_scripts() { ?> <script type=”text/javascript”> jQuery(‘#postdiv, #postdivrich’).prependTo(‘#your_meta_box_id .inside’ ); </script> … Read more

Add custom fields within meta box class “on the fly”

Agreed, I’ve seen it too, but I don’t think there’s any readily available API or method. For me, I use a lick of jQuery; <input type=”text” class=”list-item” name=”list_items[]” /> <input type=”button” class=”button-secondary” id=”add-list” /> <script type=”text/javascript”> ( function( $ ) { $( ‘#add-list’ ).click( function() { var $item = $( ‘.list-item:last’ ), $new = $item.clone(); … Read more

Custom Meta Boxes: multiple fields within a repeatable field

Try Fieldmanager. It was built with repeating groups being priority #1. Your new code would look something like this: add_action( ‘init’, function() { $fm = new Fieldmanager_Group( array( ‘name’ => ‘artists’, ‘limit’ => 0, ‘label’ => ‘New Artist’, ‘label_macro’ => array( ‘Artist: %s’, ‘name’ ), ‘add_more_label’ => ‘Add another Artist’, ‘children’ => array( ‘name’ => … Read more

wp_dropdown_categories in custom post type with custom taxonomy

get post id $post_id=get_the_ID(); get selected region $terms = wp_get_post_terms( $post_id, $taxonomy ); $selected_id=”; if(isset($terms[0]->term_id)){ $selected_id=$terms[0]->term_id; } build hierarchical dropdown wp_dropdown_categories( array( ‘show_option_all’ => ‘Choose a region’, ‘show_option_none’ => ”, ‘orderby’ => ‘ID’, ‘order’ => ‘ASC’, ‘show_count’ => 0, ‘hide_empty’ => 0, ‘child_of’ => 0, ‘exclude’ => ”, ‘echo’ => 1, ‘selected’ => $selected_id, ‘hierarchical’ … Read more

Listen to Post action

This is more of a JavaScript the A WordPress Question but anyway, You can use the JavaScript onbeforeunload event something like: <script type=”text/javascript”> old = window.onbeforeunload; window.onbeforeunload = MyOnExit; function MyOnExit(){ //do your stuff here return old(); } </script>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)