• One last question about Post Formats..

    I would like to rename the Post Formats (names) in the backend only.
    When i start writing a blog-post i now have the option of, Standard, Aside and Gallery.

    Now that i have made 3 different template files and layouts for each post formats i would like to rename them all different, more to what layout it will become.
    Standard –> Small
    Aside –> Center
    Gallery –> Wide

    after searching in Google i found lots of pages with this functions.php hook.

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

    It’s all working but how can i change the other two post formats?
    (back-end only)

    If i duplicate this code underneath it (copy-/paste) it will break my WordPress site by a WhitePage.

    Thank you..

Viewing 1 replies (of 1 total)
  • You have to insert anotger function fot the second post rename like

    function rename_post_formats_2( $safe_text ) {
        if ( $safe_text == 'Link' )
            return 'NewTip';
        return $safe_text;
    }
    add_filter( 'esc_html', 'rename_post_formats_2' );

    before

    //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');
Viewing 1 replies (of 1 total)
  • The topic ‘Renaming Post Formats backend only’ is closed to new replies.