7

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!

6 Answers 6

6

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');
24

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);
3
  • This is the right answer. +1
    – elvismdev
    Nov 11, 2016 at 22:21
  • This completely overrides post format labels. To fix this check if $text is mentioned in$names like so: if ($context == 'Post format' && in_array($text, array_keys($names)) )
    – Oleg
    Jun 13, 2020 at 16:42
  • I wouldn't personally add the additional check - first the list of post formats is very short and not extendable so you don't have to worry about other text; second the str_replace() will not affect text that isn't in the $names array anyway, so the extra check is redundant.
    – Tom Auger
    Feb 7, 2022 at 13:35
6

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.

4

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

1

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

0

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.

1
  • 1
    Hi Mike, welcome to WP.SE. This site is a little different than your usual forum (see tour) as it needs clear answers. If you have additional questions or comments on answers, please leave them as a comment there (as soon as you have gained enough reputation). Please take a look at the help center to see how the site works in detail. Thanks for answer tough. Have fun!
    – kaiser
    Jan 7, 2015 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.