WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Inside the WordPress admin dashboard there is a button for making the left side menu collapse (to show just icons and not the icons + text on left side). How can I add jQuery so that it gets automatically collapsed once my plugin opens up. I tried this but it didn't work for me. I want to give a sort of 'full screen' option inside dashboard. Can anyone help me on this?

I tried adding this jquery script to make it work, but it didn't work for me:

jQuery(document).ready(function() {
share|improve this question

You have to trigger the click event. Try,

jQuery(document).ready(function() { jQuery("#collapse-menu").trigger('click'); });

Update: Use the following code to check if menu is already folded, if not trigger click event to fold it.

jQuery(document).ready(function() {
    if ( !$(document.body).hasClass('folded') ) {
share|improve this answer
Great it works thanks, can I make it some way like this that it always make it trigger to full screen, rite now when i do refresh the click action again happens because of trigger and the menu come back to uncollapse mode – user863541 Dec 28 '11 at 6:15
Updated the answer and added the check. Try it out. – tamilsweet Dec 28 '11 at 11:44
Great, its working perfect, Thanks TamilSweet – user863541 Dec 29 '11 at 0:36

None of that worked for me. I had to use jQuery(document.body).addClass('folded'); Wordpress jQuery didnt like $(document.body).hasClass('folded'), I had to modify. Snippet below.

   jQuery(document).ready(function() {
    if ( !jQuery(document.body).hasClass('folded') ) {
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.