WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to add a column to the manage screen that displays the Title and url of the post. I got the Title to work but it's not pulling the url. Basically I just want to show the url that's not been cut of like what sometimes happens in the edit screen. Here's my code:

function change_columns( $cols ) {
$cols = array(
'cb'       => '<input type="checkbox" />',
'title'       => __( 'Title'),
'url'      => __( 'URL',      'trans' ),
return $cols;    
add_filter( "manage_cf-link_posts_columns", "change_columns" );

function custom_columns( $column, $post_id ) {
global $post;
switch ( $column ) {
case "url":
  $url = get_post_meta( $post_id, 'url', true);
  echo '<a href="' . $url . '">' . $url. '</a>';

add_action( "manage_cf-link_posts_custom_column", "custom_columns", 10, 2 );

Any help in the right direction is much appreciated.

Thanks, Phil

share|improve this question
are you sure that 'url' is the name of the field and that it has any content? – Bainternet Mar 6 '12 at 11:08
Why not get_permalink( $post_id );? – toscho Mar 6 '12 at 11:19
I swore I tried that.. but it was 3:30 am. I just replaced the get_post_meta with the get_permalink and it worked. I think when I tried that I had forgotten to call the global $post variable. Thanks! – krazymatty Mar 6 '12 at 20:56
Okay, then I move my comment to an answer. :) – toscho Mar 6 '12 at 23:17
up vote 1 down vote accepted

Always use get_permalink( $post_id ) to get the URI of a post. It takes care of changed permalink structures and SSL.

Be aware that the similar named function the_permalink() does not accept a parameter. To get the permalink of a custom post type (or a regular post outside of the loop) you have to use get_permalink().

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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