Site icon Régis Enguehard

WordPress : Ajouter l’image en une dans la liste des articles

2 fonctions sont utilisés :

function reg_columns($column) {
    // Si l'on souhaite masquer des colonnes
    // unset($column['cb']);            // Checkbox
    // unset($column['title']);
    // unset($column['author']);
    // unset($column['categories']);
    // unset($column['tags']);
    // unset($column['comments']);
    // unset($column['date']);

    $column['imageenune'] = 'Image';
    return $column;
}
add_filter('manage_post_posts_columns', 'reg_columns');

function reg_rows($column, $post_id) {
    $custom_fields = get_post_custom($post_id);
    switch ($column) {
        case 'imageenune':
            the_post_thumbnail('thumbnail');
        break;
        default:
        break;
    }
}
add_action('manage_post_posts_custom_column', 'reg_rows', 10, 2);
Quitter la version mobile