Change page name in admin 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 ?

Topic wp-list-pages admin pages Wordpress

Category Web


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;
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.