Permalink
Browse files

Hide the category post meta box, because I'm using categories as post…

… formats. Auto-set the post to the proper post format though.
  • Loading branch information...
danielbachhuber committed Apr 27, 2013
1 parent de7551e commit 453e449af2ff266f2ad2a9b9ddd1be86311e1719
Showing with 34 additions and 0 deletions.
  1. +34 −0 functions.php
@@ -1 +1,35 @@
<?php
/**
* Categories are old skool
*/
add_action( 'add_meta_boxes', 'td_remove_category_meta_box', 100 );
function td_remove_category_meta_box() {
remove_meta_box( 'categorydiv', 'post', 'side' );
}
/**
* ... but we still need them for things not to break :(
*/
add_action( 'save_post', 'td_assign_category_from_post_format' );
function td_assign_category_from_post_format( $post_id ) {
if ( 'post' != get_post_type( $post_id ) )
return;
$post_format = get_post_format( $post_id );
$formats_to_categories = array(
'aside' => 'asides',
'gallery' => 'galleries',
'photo' => 'photos',
'quote' => 'quotes',
'status' => 'statuses',
'video' => 'videos',
);
if ( isset( $formats_to_categories[$post_format] ) )
$category = $formats_to_categories[$post_format];
else
$category = 'posts';
wp_set_object_terms( $post_id, array( $category ), 'category' );
}

0 comments on commit 453e449

Please sign in to comment.