Created
March 29, 2023 12:55
-
-
Save dantetesta/3d0f7d24b4e6bf2e40e0eb0ba980aefd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adiciona a coluna de imagem do autor na lista de posts do CPT Professor | |
add_filter('manage_professor_posts_columns', 'add_author_image_column'); | |
function add_author_image_column($columns) { | |
$columns['author_image'] = __('Author Image', 'text-domain'); | |
return $columns; | |
} | |
// Mostra a imagem do autor na coluna de imagem do autor da lista de posts do CPT Professor | |
add_action('manage_professor_posts_custom_column', 'show_author_image_column', 10, 2); | |
function show_author_image_column($column, $post_id) { | |
if ($column == 'author_image') { | |
$author_id = get_post_field('post_author', $post_id); | |
$profile_picture = get_user_meta($author_id, 'profile-picture', true); | |
if ($profile_picture) { | |
echo '<img src="' . esc_attr($profile_picture) . '" width="50" height="50" />'; | |
} else { | |
echo '-'; | |
} | |
} | |
} | |
// Reorganiza as colunas na lista de posts do CPT Professor | |
add_filter('manage_professor_posts_columns', 'move_author_image_column'); | |
function move_author_image_column($columns) { | |
$new_columns = array(); | |
$author_image = $columns['author_image']; | |
unset($columns['author_image']); | |
$new_columns['author_image'] = $author_image; | |
return array_merge($new_columns, $columns); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment