Hot answers tagged

7

To display a metabox collapsed or closed by default, it is good to know that adding closed to it's class attribute will display it closed. All meta-boxes main divs that have closed in their classname, are displayed in the closed form. When the arrow is clicked it will be removed or added (toggled). This is done interactively on the post editor page. ...


5

Another way to do this is to use the hook in get_user_option: function closed_meta_boxes( $closed ) { if ( false === $closed ) $closed = array( 'submitdiv', 'postcustom', 'anothermetaboxid' ); return $closed; } add_filter( 'get_user_option_closedpostboxes_{post_type_slug}', 'closed_meta_boxes' );


2

Add a javascript to all admin pages: add_action( 'admin_print_scripts', 'auto_collapse_menu' ); function auto_collapse_menu(){ wp_enqueue_script( 'autocollapsemenu', plugins_url( 'autocollapsemenu.js', __FILE__ ), array( 'jquery' ), false, true ); } The javascript: jQuery(document).ready( function($){ // catch every click inside element with ...


2

Found it! Intuitive Category Checklist


1

You can do this with a built in WordPress query property $the_query->current_post (first post will be 0) without the need to setup a counter: <?php get_header(); ?> <?php $args = array( 'post_type' => 'question', 'order' => 'ASC' ); $the_query = new WP_Query( $args ); ?> <div class="wrap"> <...


1

Never mind I got it. I used <?php the_ID(); ?> to set unique id's but even so that was not the problem. Turns out the first accordion had a class of "in" so the real question was How can I only give a class to the first post of a loop? and I did that by using a simple counter. <?php $c = 0; ?> increment it at the end of the loop then give a ...


1

The problem is that you're not assigning a unique ID to each popup element. HTML element IDs should be unique, and each time you call animatedcollapse.show( 'script-sample' ) it will target the first element with the id "script-sample". What you could do is assign a unique ID to each popup element by using the post IDs: <div id="script-sample-<?php ...


1

By default, Wordpress saves the open/close state of these metaboxes each time you toggle it. This is done via javascript, requesting an ajax endpoint on the server. You need to find out if that request is still send or not. If it's not send (e.g. javascript error, blocked by some plugin), then you found the cause. If it is send, you need to find out if the ...


1

You could hook onto the user register hook and apply the postbox state changes then, it would simply run whenever a new user is created. add_action( 'user_register', 'set_user_closedboxes' ); function set_user_closedboxes( $uid ) { update_user_meta( $uid, 'closedpostboxes_{type}',array('submitdiv','postcustom')); } Where {type} should be your ...



Only top voted, non community-wiki answers of a minimum length are eligible