投稿フォーマットの名前を変更する

閲覧画面

管理画面

管理画面での 投稿フォーマットの ラベル文字列の変更と、テンプレートでの変更文字列の表示方法について、
(post_class()で出力するクラス名は、変更しません)

<?php
/**
 * template function
 *
 *
 *
 */
//なんかの時に使いそうな関数 
		get_post_format( ); 
		set_post_format( $post, 'aside' );
		has_post_format( $format, $post= null );
		get_post_format_link( $format );

// 変更したラベル名をテンプレートで表示
	$post_format 		= get_post_format();
	$post_format_translate = get_post_format_strings() ;
	
	echo $post_format_translate[$post_format];

/**
 * functions.php
 *
 *
 *
 */
//投稿フォーマットの登録
add_theme_support(
		 'post-formats', 
				array( 'aside', 
					'chat', 
					'gallery',
					'image',
					'link',
					'quote',
					'status',
					'video',
					'audio' 
				) 
);
				
// ラベルを フィルタで他の表示に差し替える

add_filter('gettext_with_context', 'change_label_post_formats', 10, 4);
 
function change_label_post_formats($translation, $text, $context, $domain) {
 $names= array(
 'Aside'=> '付録', 
		'Chat'=> 'チャット',
		'Gallery'=> 'ギャラリ',
		'Image'=> '画像',
		'Link'=> 'リンク',
		'Quote'=> '引用',
		'Status'=> '近況',
		'Video'=> '動画',
		'Audio'=> 'オーディオ'
		);
 if ($context== 'Post format') {
 $translation= str_replace(array_keys($names), array_values($names), $text);
 }
 return $translation;
}

?>

[emulsion_relate_posts]