コード内容：テーマをカスタム背景に対応させる例
コードの記述先：functions.php
-------------------------------------------------------
<?php
add_custom_background();
?>
-------------------------------------------------------


コード内容：カスタム背景のプレビューにiframでサイトを表示する例
コードの記述先：functions.php
-------------------------------------------------------
<?php
function admin_custom_bg_div(){
?>
    <h3><?php _e( 'Background Image' ); ?></h3>
    <table class="form-table">
        <tbody>
            <tr valign="top">
                <th scope="row"><?php _e( 'Preview' ); ?></th>
                <td><iframe id="preview" src="<?php echo esc_attr(get_option( 'siteurl' )); ?>" height="400" style="width:100%"></iframe>
<?php
}
function admin_custom_bg(){
?>
    <script type="text/javascript">
        //<![CDATA[
        function _pickColor(color) {
            jQuery('#preview').contents().find('body').css('background-color', color);
        }
        jQuery(document).ready(function() {
            jQuery('#background-color').keyup(function() {
                var _hex = jQuery('#background-color').val(), hex = _hex;
                if ( hex.charAt(0) != '#' )
                    hex = '#' + hex;
                hex = hex.replace(/[^#a-fA-F0-9]+/, '');
                if ( hex != _hex )
                    jQuery('#background-color').val(hex);
                if ( hex.length == 4 || hex.length == 7 ){
                    pickColor( hex );
                    _pickColor( hex );
                }
            });
            jQuery('input[name="background-position-x"]').change(function() {
                jQuery('#preview').contents().find('body').css('background-position', jQuery(this).val() + ' top');
            });
            jQuery('input[name="background-repeat"]').change(function() {
                jQuery('#preview').contents().find('body').css('background-repeat', jQuery(this).val());
            });
            jQuery('input[name="background-attachment"]').change(function() {
                jQuery('#preview').contents().find('body').css('background-attachment', jQuery(this).val());
            });
            farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) {
                pickColor(color);
                _pickColor(color);
            });
            pickColor(jQuery('#background-color').val());
            _pickColor(jQuery('#background-color').val());
        });
        //]]>
    </script>
<?php
}
function theme_setup(){
    add_custom_background( '', 'admin_custom_bg', 'admin_custom_bg_div' );
}
add_action( 'after_setup_theme', 'theme_setup' );
?>
-------------------------------------------------------