programing

워드프레스 관리 영역에서 메뉴 항목 레이블을 변경하시겠습니까?

javajsp 2023. 10. 16. 21:31

워드프레스 관리 영역에서 메뉴 항목 레이블을 변경하시겠습니까?

관리 구역 안에서 메뉴 항목의 라벨을 변경할 수 있는 방법이 있습니까?새 사용자 지정 게시 유형을 등록할 때와 같이 기본 메뉴 항목에 대한 모든 레이블을 지정할 수 있습니다.

미리 감사드립니다!

add_filter( 'gettext', 'change_post_to_article' );
add_filter( 'ngettext', 'change_post_to_article' );

function change_post_to_article( $translated ) 
{  
    $translated = str_replace( 'Post', 'Article', $translated );
    $translated = str_replace( 'post', 'article', $translated );
    return $translated;
}

다른 방법이 있습니다. 자세한 내용은 이 답변을 확인하십시오.

최선의 해결책은 이것입니다. 그냥 당신의 기능에 써주세요.php 또는 플러그인 파일

function change_post_menu_label() {
    global $menu;
    global $submenu;
    $menu[70][0] = 'Articles';
    $submenu['user-edit.php'][5][0] = 'Articles';
    $submenu['user-edit.php'][10][0] = 'Add Articles';
    echo '';
}
function change_post_object_label() {
        global $wp_post_types;
        $labels = &$wp_post_types['users']->labels;
        $labels->name = 'Articles';
        $labels->singular_name = 'Article';
        $labels->add_new = 'Add Article';
        $labels->add_new_item = 'Add Article';
        $labels->edit_item = 'Edit Article';
        $labels->new_item = 'Article';
        $labels->view_item = 'View Article';
        $labels->search_items = 'Search Articles';
        $labels->not_found = 'No Articles found';
        $labels->not_found_in_trash = 'No Articles found in Trash';
}
add_action( 'init', 'change_post_object_label' );
add_action( 'admin_menu', 'change_post_menu_label' );

참고로, 현재 회사 블로그에서 해당 코드에 대한 새로운 참조: http://www.get10up.com/blog/2011/03/customizing-wordpress-admin/

PHP5에서 스트라이프를 사용하면 두 번의 호출을 피할 수 있습니다.

// Apps Store로 플러그인 이름 바꾸기

function rename_plugin_menu() {  
    global $menu;       
    $menu[65][0] = 'Apps Store'; // Change Users to Customers main id
}  
add_action( 'admin_menu', 'rename_plugin_menu' );  

언급URL : https://stackoverflow.com/questions/4340266/change-menu-items-labels-in-wordpress-admin-area