Hi, i’m trying to make admin column to an custom post type.
It’s working but i didint manage to apply filters that work on each column title.
function realisations_custom_column ( $column, $post_id ) {
switch ( $column ) {
case 'mise_en_avant':
echo get_post_meta( $post_id, 'forward_realisations', true );
break;
case 'type_de_produit':
global $post;
$groupField = get_field('type_de_produit');
echo $groupField['type_de_produit_name'];
break;
case 'departement':
echo get_post_meta ( $post_id, 'choix_du_departement', true );
break;
}
}
add_action ( 'manage_realisations_posts_custom_column', 'realisations_custom_column', 10, 2 );
/*
* Add Sortable columns
*/
function my_column_register_sortable( $columns )
{
$columns['mise_en_avant'] = 'mise_en_avant';
$columns['type_de_produit'] = 'type_de_produit';
$columns['departement'] = 'departement';
return $columns;
}
add_filter("manage_edit-realisations_sortable_columns", "my_column_register_sortable" );
On click of the arrow, the data are not shorted proprely. Do i misunderstand the manage_edit- function ?
You need to add a pre_get_posts filter. See the last step in this tutorial.
Thanks, i had an another problem, but all is solve !