renaming portfolio label and passing client in column
This commit is contained in:
parent
6cfcfa271b
commit
4c582fdac1
|
|
@ -26,14 +26,15 @@ function cpt_customer()
|
||||||
register_post_type(
|
register_post_type(
|
||||||
'portfolio',
|
'portfolio',
|
||||||
array(
|
array(
|
||||||
'label' => __('Portfolio'),
|
'label' => __('Projets'),
|
||||||
'singular_label' => __('Portfolio'),
|
'singular_label' => __('Projets'),
|
||||||
'public' => true,
|
'public' => true,
|
||||||
'menu_icon' => 'dashicons-forms',
|
'menu_icon' => 'dashicons-forms',
|
||||||
'show_ui' => true,
|
'show_ui' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array('title', 'thumbnail', 'editor', 'excerpt', 'custom-fields', 'revisions', 'page-attributes'),
|
'supports' => array('title', 'thumbnail', 'editor', 'excerpt', 'custom-fields', 'revisions', 'page-attributes'),
|
||||||
'show_in_rest' => true, // Active l'éditeur de blocs (Gutenberg).
|
'show_in_rest' => true, // Active l'éditeur de blocs (Gutenberg).
|
||||||
|
'rewrite' => array('slug' => 'projets'),
|
||||||
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -43,3 +44,42 @@ add_action('init', 'cpt_customer');
|
||||||
function my_custom_post_type() {}
|
function my_custom_post_type() {}
|
||||||
|
|
||||||
add_action('init', 'my_custom_post_type');
|
add_action('init', 'my_custom_post_type');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
DÉCLARATION DES COLONNES CUSTOM DANS LA LISTE DES POSTS ARTISANS
|
||||||
|
------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// **** AJOUT DES COLONNES
|
||||||
|
function deligraph_projets_add_acf_posts_columns($columns)
|
||||||
|
{
|
||||||
|
global $current_screen;
|
||||||
|
|
||||||
|
|
||||||
|
$customColumns = array(
|
||||||
|
'client' => 'Client',
|
||||||
|
);
|
||||||
|
$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_portfolio_posts_columns', 'deligraph_projets_add_acf_posts_columns');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
GESTION DE LA VALEUR DE CHAQUE COLONNE
|
||||||
|
------------------------------------------------------------------------*/
|
||||||
|
function deligraph_projets_handle_posts_custom_columns($column)
|
||||||
|
{
|
||||||
|
|
||||||
|
$post_id = get_the_ID();
|
||||||
|
|
||||||
|
if ($column == 'client') {
|
||||||
|
$client = get_field('client_name', $post_id);
|
||||||
|
if (!$client) return;
|
||||||
|
echo $client;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action('manage_portfolio_posts_custom_column', 'deligraph_projets_handle_posts_custom_columns', 10, 2);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user