1

I want to add the Page URL as a custom column to the Pages admin table. Here is where I am at with the code. Code is in the theme's functions.php.

function lrh_modify_page_table( $column ) {
    $column['lrh_url'] = 'URL';

    return $column;
}
add_filter( 'manage_pages_columns', 'lrh_modify_page_table' );

function lrh_modify_page_table_row( $column_name, $post_id ) {

    $url = get_permalink( $post_id, true);

    switch ($column_name) {
        case 'lrh_url' :
            echo $url;
            break;

        default:
    }
}

add_action( 'manage_pages_custom_column', 'lrh_modify_page_table_row', 10, 2 );

Right now it is returning the url as http://example.com/%pagename%/. How do I get it to return the actual URL of the page?

0

Remove the true parameter in the get_permalink function

$url = get_permalink( $post_id );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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