The first thing to remember about the post editing screen is that everything (except for the post title, editors, permalink, etc.) is a meta box. Since you can easily add and remove meta boxes, there's no need for CSS and JS hacking. Don't want the standard post format to show up? Remove the default meta box and roll your own.
First hook into add_meta_boxes_{$post_type}
and remove the old format div, and add your own.
<?php
add_action( 'add_meta_boxes_post', 'wpse41940_meta_boxes' );
function wpse41940_meta_boxes( $post )
{
remove_meta_box(
'formatdiv',
$post->post_type,
'side'
);
add_meta_box(
'wpse41940_formatdiv',
_x( 'Format', 'post format' ),
'wpse41940_format_meta_box',
$post->post_type,
'side',
'core'
);
}
You can find the code for the default post format meta box in wp-admin/includes/meta-boxes.php
inside the function post_format_meta_box
. Here it is:
<?php
function post_format_meta_box( $post, $box ) {
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
$post_formats = get_theme_support( 'post-formats' );
if ( is_array( $post_formats[0] ) ) :
$post_format = get_post_format( $post->ID );
if ( !$post_format )
$post_format = '0';
// Add in the current one if it isn't there yet, in case the current theme doesn't support it
if ( $post_format && !in_array( $post_format, $post_formats[0] ) )
$post_formats[0][] = $post_format;
?>
<div id="post-formats-select">
<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0"><?php _e('Standard'); ?></label>
<?php foreach ( $post_formats[0] as $format ) : ?>
<br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
<?php endforeach; ?><br />
</div>
<?php endif; endif;
}
The easiest thing to do is to copy the entire deal, rename the function and change the stuff we need to change. Name, that means changing this:
$post_format = get_post_format( $post->ID );
if ( !$post_format )
$post_format = '0';
To the following to set the "default format" to aside (or whatever you want it to be).
$post_format = get_post_format( $post->ID );
if ( !$post_format )
$post_format = 'aside';
We'll also need to remove this line:
<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0"><?php _e('Standard'); ?></label>
Which is the "standard" post format. The final result:
<?php
function wpse41940_format_meta_box( $post, $box )
{
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
$post_formats = get_theme_support( 'post-formats' );
if ( is_array( $post_formats[0] ) ) :
$post_format = get_post_format( $post->ID );
if ( !$post_format )
$post_format = 'aside';
if ( $post_format && !in_array( $post_format, $post_formats[0] ) )
$post_formats[0][] = $post_format;
?>
<div id="post-formats-select">
<?php foreach ( $post_formats[0] as $format ) : ?>
<input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label><br/>
<?php endforeach; ?><br />
</div>
<?php endif; endif;
}
Finally, it would be a good idea to make sure get_post_format
never returns false, or, rather, also returns your default format in the absence of a format. Post formats are just a taxonomy, so we can hook into get_the_terms
and make sure we always have a post format. Formats are created as posts are added to them, so we have to add the taxonomy if it doens't exist already.
<?php
add_filter( 'get_the_terms', 'wpse41940_filter_formats', 10, 3 );
function wpse41940_filter_formats( $terms, $post_id, $taxonomy )
{
if( 'post_format' != $taxonomy ) return $terms;
if( empty( $terms ) )
{
$aside = get_term_by( 'slug', 'post-format-aside', 'post_format' );
// post formats are created as posts are saved in them.
// so this is a bit of a hack
if( $aside )
{
$terms[] = $aside;
}
else
{
$term = wp_insert_term( 'post-format-aside', 'post_format' );
$terms[] = get_term( $term['term_id'], 'post_format' );
}
}
return $terms;
}
Here is all that as a plugin.