WordPress.org

Ready to get started?Download WordPress

Forums

Renaming Post Formats backend only (2 posts)

  1. Jaja..
    Member
    Posted 2 years ago #

    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..

  2. Sebastian
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.