Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Thomas

Column with a link

Hi

Im using the pro version.

I want to add a column with an external link. no I want to add to this link the recent post-id, for exampl http://www.sample.com?mypost=POST-ID . How can I add such a custom row? With the type “link”? But how I can add then the post id?

thanks a lot for your answer.

Thomas

7 years, 7 months ago
Stefan van den Dungen Gronovius
Developer

Since we have no custom column for that you have to alter the value for your column yourself.
So say you use the custom field column, you can setup the column as normal.
Next, you can use this filter in your code to change the value
https://www.admincolumns.com/documentation/filter-reference/cac-column-meta-value/

For example, if you have a custom field that returns the ID that you want to use in your URL, you can do something like this.

function my_column_meta_value_create_link( $value, $object_id, $column ) { 
  $custom_field_key = 'this_is_your_custom_key'; 
  if ( 'column-meta' == $column->get_type() && $custom_field_key == $column->get_field() ) { 
    $value = 'http://www.sample.com?mypost=' . $value; 
  } 
  return $value; 
} 
add_filter( 'cac/column/meta/value', 'my_column_meta_value_create_link', 10, 3 );

It adds the current value (ID) to the string (website) that you choose.
Hopefully this make sense. If you have any questions, please let me know.

7 years, 7 months ago
Andrew

Hello, bringing this idea back up from the dead, is this still the best way to handle this idea? Any plans to allow the fields to have a link as well. In many cases we are using external links and will be an amazing feature to just add a link to a displayed value, or I’m just not seeing the way to do this inside Admin Column.

I tried the before after “> data id idea, with no luck, that’s not what I’m after, for obvious reasons, no way to know the custom field used between the a tags open and closing, it can work, but clunky at best.

Thanks

1 year, 6 months ago

You must be logged in to reply to this topic.