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 use this function to get some information to the user columns,

function column_company( $defaults ) {
    $defaults['usercolumn-company'] = __('Company', 'user-column');
    $defaults['usercolumn-myoffers'] = __('Applied Offers', 'user-column');
    $defaults['usercolumn-totaloffers'] = __('Total Offers', 'user-column');
    return $defaults;

function custom_column_company($value, $column_name, $id) {
    if( $column_name == 'usercolumn-company' ) {
        return get_the_author_meta( 'company', $id );
    elseif( $column_name == 'usercolumn-myoffers' ) {
        return get_the_author_meta( 'offersiget', $id );
    elseif( $column_name == 'usercolumn-totaloffers' ) {
        return get_the_author_meta( 'totaloffers', $id );

add_action('manage_users_custom_column', 'custom_column_company', 15, 3);
add_filter('manage_users_columns', 'column_company', 15, 1);

i return the get_the_author_meta( 'offersiget', $id );

and here i get from the db some post id's as text, like: 8,12,51

is it possible to return this, not as a text but as a link to the edit post

I try this by @hakre

return sprintf('<a href="/wp-admin/post.php?post='.get_the_author_meta( 'offersiget', $id ).'&action=edit">'.get_the_author_meta( 'offersiget', $id ).'</a>');

and it works but it return one link with all the post id's inside, is it possible to split them?

any help?


share|improve this question
up vote 1 down vote accepted

Your get_the_author_meta() calls must be returning a string(following your comments), so what you'll need to do is split that string up into an array, loop over it and build an array of links, then join it back together at the end using a seperator.

    Meh, no license, do as you want with it..
    Example code
function ids_to_post_editlink( $ids = array(), $seperator = ' ' ) {
    if( empty( $ids ) || '' == $ids )

    if( !is_array( $ids ) )
        $ids = explode( ',', $ids );

    $links = array();
    $ids   = array_map( 'intval', $ids );

    foreach( $ids as $pid )
        $links[] = "<a href='" . admin_url( "post.php?action=edit&post=$pid" ) . "'>$pid</a>";

    return implode( $seperator, $links );

Add that function alongside your code, then update your get_the_author_meta calls to one of the following..

 // Default(space seperated)
 return ids_to_post_editlink( get_the_author_meta( 'your-meta-key', $id ) );

 // Comma seperated 
 return ids_to_post_editlink( get_the_author_meta( 'your-meta-key', $id ), ', ' );

 // Pipe seperated 
 return ids_to_post_editlink( get_the_author_meta( 'your-meta-key', $id ), ' | ' );

Hope that helps..

share|improve this answer
thanks a lot @t31os, it's working fine! – Philip Jan 21 '11 at 20:19
Happy to help.. :) – t31os Jan 22 '11 at 9:31
I consider that a derivative work of mine :P – hakre Jan 22 '11 at 10:43
Consider it all you like.. ;) – t31os Jan 22 '11 at 10:50
lol, i got a downvote, i seriously hope that's not for my comment above, or comments at the top of the code i provided, code of which i could of written with my eyes closed(and i'm not joking either). Be curious to hear why someone down-voted the answer. – t31os Jan 23 '11 at 9:42

As far as you're concerned to build a link based on the postID, this is some example code:

 * Copyright 2011 by hakre <http://hakre.wordpress.com/>, some rights reserved
 * Provided AS-IS, example code only. 
 * Licensed under CC BY-SA 2.5, needs attribution.
 *   * Author: hakre <http://hakre.wordpress.com/> 
 *   * Where : With the code and the visible portion of 
 *             any remixed work.
 * Exceptions to this need the written form.
 * If you make use of this code, please send me a deposit copy, thx.
# get the link for a specific postId
$getPostIdLink = function($postId) {
    return sprintf('/wp-admin/post.php?post=%d&action=edit', $postId);
$getHtmlOfLinks = function($postIdsCommaSeperatedText) use ($formatPostIdLink) {
    $links = array_map(function($postId) use ($formatPostIdLink) {
        $postId = intval(trim($postId));
        if ($postId) {
            $link = $formatPostIdLink($postId);
            return sprintf('<a href="%s">(%d)</a>', $link, $postId);
        } else {
             return false;
    }, explode(',', $postIdsCommaSeperatedText));
    $links = array_filter($links);
    return implode(', ', $links);

echo $getHtmlOfLinks('8,12,51'); # do the output, 
# should give you (8), (12), (51) [brackets are linked]

or for your updated question:

return $getHtmlOfLinks(get_the_author_meta( 'offersiget', $id ));
share|improve this answer
i use this and i get one link with (12,21,123)ids, i will update the question! – Philip Jan 21 '11 at 17:51
I updated the code, this one is splitting your comma separated list of IDs. – hakre Jan 21 '11 at 18:23

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.