0

Inside WordPress admin panel, there is the "old" link manager, know also a Bloggroll.

It has multiple columns in the overview, and I would like to add a column. How can I do this?

(I only want to know, how to add a column into the overview. Or with other words: How can I add some HTML code to the output?)

This link manager is available with http://domain/wp-admin/link-manager.php

  • did you mean you want to add columns in admin screen when you list out the links? – simongcc Apr 16 at 7:18
  • @simongcc: Yes. (I've edit the question, thank you.) – Tahtu Apr 16 at 7:29
  • I have revised the solutions specified for link and explained the reason. – simongcc Apr 16 at 8:43
0

Normally, default post and custom post type screen could use the following

However, links is not a post type and the data is in its own database table, different to post table.

While the column header still follows the above filter. For the column data of the list in link manager, the filter is manage_link_custom_column

You may use the following code to do so. The following is tested on theme functions.php and proved to work assumed there is no interference from other plugins and the theme itself.

// add column header
add_filter('manage_link-manager_columns', 'add_columns_to_lm');
function add_columns_to_lm( $columns )
    {
        $newcolumns = array(
            'custom_header' => 'new custom header', // header key => value
    );
    $columns = array_merge($newcolumns, $columns); // just one of the writing style, it is up to you to change

    return $columns;
}

// add column data
add_action('manage_link_custom_column', 'add_column_data_to_lm', 10, 2);
function add_column_data_to_lm( $column, $link_id ) {
    //  var_dump( $link_id ) // for manipulations

     if( $column === 'custom_header' ) { // match the header key which you define the new header
        echo 'something inside';
     }
}
| improve this answer | |
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – cjbj Apr 16 at 8:37
  • I have updated the answers. Sorry for the gap between since I found some mistakes. I have commented to him. – simongcc Apr 16 at 8:44
  • Thank you, this is what I'm looking for! – Tahtu Apr 16 at 11:06
  • Glad it helps. I guess WP hide out the link manager because it is not a standard post type and custom post type could do the same with extensibility and flexibility with different plugins or custom code. – simongcc Apr 17 at 2:45

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.