Is it possible to rename a post format?

Since WP 3.1, it’s been possible to use Tumblr-style post formats. I want to use the ‘aside’ option in a theme, but I want it to have a different title in the WP admin area.

So, for example, when a user is writing a post, they have the option for the post to be, say, either ‘Standard’ or ‘Quick’ — rather than ‘Standard’ or ‘Aside’.

Is it possible to do this without modifying the core? It’d be great if it’s something that could be pretty easily done via functions.php or the like. I live in hope…

Thanks!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I think this is the only way for now. Put this in your functions.php in your theme folder or create a simple plugin:

function rename_post_formats( $safe_text ) {
    if ( $safe_text == 'Aside' )
        return 'Quick';

    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("Quick");             
            });

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

Method 2

A much more reliable (and less hacky) way to do this would be the following:

function rename_post_formats($translation, $text, $context, $domain) {
    $names = array(
        'Audio'  => 'Podcast',
        'Status' => 'Tweet'
    );
    if ($context == 'Post format') {
        $translation = str_replace(array_keys($names), array_values($names), $text);
    }
    return $translation;
}
add_filter('gettext_with_context', 'rename_post_formats', 10, 4);

Method 3

Post formats are hard-coded into WordPress. You can’t change them, but as JohnnyPea points out you can hide the existing name with a couple of tricks.

Chip Bennett recommends setting up your own custom taxonomy if you really need to create your own set of post formats, and I strongly second that recommendation.

But take a second to think about this. Post formats are designed to help you style the output of your blog for the reader. The reader doesn’t care if it’s called an Aside or a Quick, they just care how the post content is presented. If you’re just trying to change the post format label on the admin side for yourself, then please just roll your own custom taxonomy and use that.

Method 4

The correct method would be to register a custom taxonomy, and not use core Post Formats at all.

Method 5

I’ve customized the post formats and display them in a tab bar horizontally along the top of the post editor page. I customize their names a lil somethin like this. It is quite an involved and hackish process but I pasted it into a Gist if you’d like to check it out: https://gist.github.com/dcondrey/059dec0c5b01197c9f11

Final result comes out looking somethin like this:

enter image description here

Method 6

I see nothing wrong with altering the title of these post formats to suit the needs of your editorial team and process. Unless changing the names would break theme functionality from rendering them properly. The idea behind these formats is that a theme can state which are supported and only those would be listed in the editor.

From what I can tell @JohnyPea’s method would not break anything on the theme side. I am curious if anyone has tried @Aaron’s method. If so were you able to switch themes without issue.

Ultimately what we are talking about is making these semantically more useful to the editorial staff and a custom post type would likely be overkill if we are only interested in a name change/synonym.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x