How to Quickly Rename a WordPress Post Format

Post Formats is a really cool theme feature added in WordPress 3.1. It’s a standardized core feature available to any WordPress theme that supports it.

However, you’re not really encouraged to create your own custom post formats. This is because post formats are meant to transfer across themes. If you were to create your own unique post format, your posts would not display correctly if you switched to a theme that only supports the standardized post formats.

If you feel like you need to create your own post format, the recommended method would be to register a custom taxonomy, which is really what the post formats feature is anyway. WordPress couldn’t make it any easier for you. Just follow the directions in the codex and get creative with all of the options.

But what if you just want to rename an existing post format? Perhaps the format itself works for you but the label on it is confusing for authors and/or readers. Maybe you’re using a theme that supports and styles all of the standard post formats and everything works perfectly for you, except you’d rather have a different label for one of them.

In this example. let’s say we want to rename ‘Aside’ to be ‘Tip’ instead. Here’s a quick tip I found in the WordPress stack exchange. It is simply for presentation – it doesn’t do anything else. Think of this more as an illusion.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function rename_post_formats( $safe_text ) {
    if ( $safe_text == 'Aside' )
        return 'Tip';

    return $safe_text;
}
add_filter( 'esc_html', 'rename_post_formats' );

//rename Aside in posts list table
function live_rename_formats() { 
    global $current_screen;

    if ( $current_screen->id == 'edit-post' ) { ?>
        <script type="text/javascript">
        jQuery('document').ready(function() {

            jQuery("span.post-state-format").each(function() { 
                if ( jQuery(this).text() == "Aside" )
                    jQuery(this).text("Tip");             
            });

        });      
        </script>
<?php }
}
add_action('admin_head', 'live_rename_formats');

Add this snippet to your functions.php file and edit it in the two places where you see the original post format, followed by your new name for it. Again, this is just a quick little hack for presentation only. Hopefully it will come in handy for some of you.

Need a little bit more background on Post Formats? Check out Siobhan’s article about how they are used in the Twenty Eleven theme: Twenty Eleven Post Formats – What Are They and Why Should I Care?