更改自定义帖子类型的 WP 管理员帖子状态过滤器 [英] Change WP admin post status filter for custom post type

查看:29
本文介绍了更改自定义帖子类型的 WP 管理员帖子状态过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改/重命名WP自定义帖子类型页面顶部的帖子状态文本

How do you change/rename the text of post statuses in the top of the WP custom post type page

全部 |已发表 |预定 |草稿

All | Published | Scheduled | Draft

推荐答案

使用过滤器 views_edit-{$post_type}.修改数组以设置所需的帖子类型:

Using the filter views_edit-{$post_type}. Modify the array to set the desired post types:

foreach( array( 'post', 'portfolio' ) as $hook )
    add_filter( "views_edit-$hook", 'modified_views_so_15799171' );

function modified_views_so_15799171( $views ) 
{
    $views['all'] = str_replace( 'All ', 'Tutti ', $views['all'] );

    if( isset( $views['publish'] ) )
        $views['publish'] = str_replace( 'Published ', 'Online ', $views['publish'] );

    if( isset( $views['future'] ) )
        $views['future'] = str_replace( 'Scheduled ', 'Future ', $views['future'] );

    if( isset( $views['draft'] ) )
        $views['draft'] = str_replace( 'Drafts ', 'In progress ', $views['draft'] );

    if( isset( $views['trash'] ) )
        $views['trash'] = str_replace( 'Trash ', 'Dustbin ', $views['trash'] );

    return $views;
}

这篇关于更改自定义帖子类型的 WP 管理员帖子状态过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆