// Add the custom columns to the job_listing post type:
add_filter( 'manage_job_listing_posts_columns', 'set_custom_edit_job_listing_columns' );
function set_custom_edit_job_listing_columns($columns) {
unset( $columns['author'] );
$columns['job_author'] = __( 'Employer', 'c2code' );
return $columns;
}
// Add the data to the custom columns for the job_listing post type:
add_action( 'manage_job_listing_posts_custom_column' , 'custom_job_listing_column', 10, 2 );
function custom_job_listing_column( $column, $post_id ) {
switch ( $column ) {
case 'job_author' :
$author_id = get_post_field( 'post_author', $post_id );
$auth_url = get_author_posts_url($author_id);
$emp = get_userdata( $author_id );
$emp_name = $emp->display_name;
$comp_name = get_user_meta($author_id, 'company_name', true);
$emp_comp = ($comp_name) ? $comp_name : $emp_name ;
echo '<a href="'.$auth_url.'" target="_blank">'.$emp_comp .'</a>';
break;
}
}
Jagdish Sarma Asked question July 14, 2022