FEATURE Add custom columns for artisan posts in admin and handle column values
This commit is contained in:
parent
901071fb9a
commit
372e16ae85
42
includes/columns.php
Normal file
42
includes/columns.php
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?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);
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import menuInit from './header';
|
import menuInit from './header';
|
||||||
console.log('menuInit');
|
|
||||||
console.log('menuIniteeeee');
|
|
||||||
window.addEventListener('load', function () {
|
window.addEventListener('load', function () {
|
||||||
menuInit();
|
menuInit();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user