what the blog?

{upgrade in progress..}

Rename Post format string in WordPress theme

Code

Because post format string is hard coded in post.php, so you can’t change them in filter way. To rename the post format string and display in a theme, you can add the following function in function.php.

function post_format_nicename() {
		global $post;
		$slug = str_replace('post-format-', '', get_post_format($post->ID));
		if(empty($slug)) {
				$slug = 'standard';
		} 
		$source = array('Standard', 'Status');
		$replacement = array(__('Blog Post', 'textdomain'),__('Status Update','textdomain'));
		$strings = str_replace($source, $replacement, get_post_format_strings());
        $string = $strings[$slug];
		return $string;
}


To display the mod-ed post formant name, call this function


echo post_format_nicename();

post_formatwordpress

levin • April 22, 2011


Previous Post

Next Post

Leave a Reply