2

Is there a way to display the page url or permalink instead of the page title on

example.com/wp-admin/edit.php?post_type=page

I am doing some A/B testing and some pages have the same title, but a different URL.

Also I may experiment from time to time with a different title. I know all my pages by URL and would prefer to see this in the list of pages.

1 Answer 1

2

Filter 'the_title' on the screen with the list table of your post type.
The pattern for the initial hook is: manage_edit-post_type_name_columns.

Sample code:

// replace 'post' with the post type name you want to catch.
add_filter( 'manage_edit-post_columns', 'wpse_67171_title_to_url' );

/**
 * Replace the default title with its permalink.
 *
 * @param  string $title
 * @param  int $id Post ID
 * @return string
 */
function wpse_67171_title_to_url( $title, $id = 0 )
{
    if ( 'the_title' !== current_filter() )
    {
        add_filter( 'the_title', __FUNCTION__, 10, 2 );
        return $title;
    }
    // strip domain name
    return parse_url( get_permalink( $id ), PHP_URL_PATH );
}

Result:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.