最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Change page name in admin list

programmeradmin4浏览0评论

One of my customer has many pages that have the same titles, although their content is different.

They would like to be able to give them "admin titles" in order to differentiate them in the admin list.

I was thinking of adding an ACF extra field "Admin Title". If this field is filled, then on the page listing in the admin, I would like to use it.

Is there an admin filter that is called when generating the page list ?

One of my customer has many pages that have the same titles, although their content is different.

They would like to be able to give them "admin titles" in order to differentiate them in the admin list.

I was thinking of adding an ACF extra field "Admin Title". If this field is filled, then on the page listing in the admin, I would like to use it.

Is there an admin filter that is called when generating the page list ?

Share Improve this question asked Oct 5, 2020 at 15:24 PierrePierre 9510 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You can use the_title hook to change the title of the post in the admin, something like this

add_filter( 'the_title', 'custom_post_title', 10, 2 );

function custom_post_title( $title, $post_id ) {

    // Return early if not in the admin
    if ( !is_admin() )
        return $title;

    $post_type = get_post_type( $post_id );

    // You only need to change the title for pages
    if ( 'page' !== $post_type )
        return $title;

    $custom_title = get_field( 'your_custom_title_acf_key', $post_id );

    // If custom title is present, display it instead of original
    if ( $custom_title ) {
        $title = $custom_title;
    }

    return $title;
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论