Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Created February 12, 2012 22:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisguitarguy/1811301 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/1811301 to your computer and use it in GitHub Desktop.
Remove the "standard" WordPress post format.
<?php
/*
Plugin Name: No Standard Post
Description: Removes the standard post format.
Author: Christopher Davis
Author URI: http://christopherdavis.me
*/
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'
);
}
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;
}
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;
}
@sandeep01082013
Copy link

sorry dear this is not good solution

@sandeep01082013
Copy link

make this by add_theme_support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment