Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm currently using a version of this function - post formats - how to switch meta boxes when changing format? which hides all meta boxes until a corresponding post format is selected (Ie; If someone selects "Video" then my custom Video meta box shows up)

But when the post is saved all the meta boxes become hidden again unless I reselect the post format.

Is there a way to show the appropriate meta box even when the post has been saved?

This is the main function;

jQuery( document ).ready( function($)
        {
            // Starts by hiding the "Video Options" meta box
            $( "#video-options" ).addClass( "hidden" );

            // If "Video" post format is selected, show the "Video Options" meta box
            $( "input#post-format-video" ).change( function() {
                $( "#video-options" ).removeClass( "hidden" );
            } );

        }
    );
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try this one:

jQuery( document ).ready( function($)
{
    // Starts by hiding the "Video Options" meta box
    $( "#video-options" ).addClass( "hidden" );

    if( $( "input#post-format-video" ).is(':checked') ){
        $( "#video-options" ).removeClass( "hidden" );
    }
    // If "Video" post format is selected, show the "Video Options" meta box
    $( "input#post-format-video" ).change( function() {
        if( $(this).is(':checked') ){
            $( "#video-options" ).removeClass( "hidden" );
        }
    } );

    }

);

share|improve this answer
    
Perfect!! Thank you –  Dean Elliott Jan 27 '13 at 21:13

Your Answer

 
discard

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.