43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
DÉCLARATION DES COLONNES CUSTOM DANS LA LISTE DES POSTS ARTISANS
|
|
------------------------------------------------------------------------*/
|
|
|
|
// **** AJOUT DES COLONNES
|
|
function carhop_articles_add_acf_posts_columns($columns)
|
|
{
|
|
global $current_screen;
|
|
|
|
// SUPPRIMER LA COLONNE 'date'
|
|
if (isset($columns['date'])) {
|
|
unset($columns['date']);
|
|
}
|
|
$customColumns = array(
|
|
'revue' => 'Revue',
|
|
);
|
|
$new_admin_col_arrays = array_slice($columns, 0, 2, true) + $customColumns + array_slice($columns, 2, count($columns) - 2, true);
|
|
return array_merge($new_admin_col_arrays);
|
|
}
|
|
add_filter('manage_articles_posts_columns', 'carhop_articles_add_acf_posts_columns');
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
GESTION DE LA VALEUR DE CHAQUE COLONNE
|
|
------------------------------------------------------------------------*/
|
|
function carhop_articles_handle_posts_custom_columns($column)
|
|
{
|
|
$post_id = get_the_ID();
|
|
|
|
if ($column == 'revue') {
|
|
$revue_id = get_field('related_revue', $post_id);
|
|
if (!isset($revue_id)) return;
|
|
|
|
$revue_title = get_the_title($revue_id);
|
|
echo $revue_title;
|
|
}
|
|
}
|
|
add_action('manage_articles_posts_custom_column', 'carhop_articles_handle_posts_custom_columns', 10, 2);
|