Please share the you code use to place content in your custom columns. If the code is more than a couple dozen lines, you should post outside of these forums and just provide the link here. A couple places where you can post your code are pastebin.com or gist.github.com.
<?php
add_filter( ‘manage_animali_posts_columns’, function( $columns ) {
$columns[ ‘anteprima’ ] = __( ‘Anteprima’ );
$columns[ ‘razza_animale’ ] = __( ‘Razza Animale’ );
$columns[ ‘data_nascita’ ] = __( ‘Data di Nascita’ );
$columns[ ‘data_ingresso’ ] = __( ‘Data di Ingresso’ );
return $columns;
} );
add_action( ‘manage_animali_posts_custom_column’, function( $column_name, $post_id ) {
$razza_animale = rwmb_get_value( ‘razza_animale’, $post_id );
$image = rwmb_get_value( ‘galleria_immagini_animale’, [ ‘size’ => ‘thumbnail’ ], $post_id )
$data_nascita = rwmb_get_value( ‘data_nascita_animale’, $post_id );
$data_ingresso = rwmb_get_value( ‘data_ingresso_animale’, $post_id );
if( ‘razza_animale’ == $column_name ) {
echo $razza_animale;
}
if ( ‘anteprima’ == $column_name ) {
echo ‘<img src=“’ . $image[ ‘url’ ] . ‘”>’;
}
if( ‘data_nascita’ == $column_name ) {
echo $data_nascita;
}
if( ‘data_ingresso’ == $column_name ) {
echo $data_ingresso;
}
}, 10, 2 );
I don’t see how altering the query results by author would affect custom columns in the list table. However, there are errors in your code that need to be addressed.
If I’m not mistaken, I think the first add_filter() call should be
add_filter( ‘manage_edit-animali_columns’, function( $columns ) {
I’m not sure how you’d get any custom columns under any query with what you have: manage_animali_posts_columns
Many of the quotes are the “curly” kind — ‘, which are not seen as quotes in PHP. They need to be changed to the “straight” kind — '.
This line was missing the terminal ;:
$image = rwmb_get_value( ‘galleria_immagini_animale’, [ ‘size’ => ‘thumbnail’ ], $post_id );
Some of these may be due to copy/paste issues into the forums. The original source may be fine. I did test your code with the above corrections, after defining rwmb_get_value() to return “test” and changing “animale” to an existing CPT of mine. I saw 4 custom columns of “test” for all of my posts as an author user.
Hello, my code is working because on an administrator interface I can see all. Maybe, as you said, is a problem on copy/past here in the forum.
For the moment I resolved the issue by delete all this custom fields from the dashboard Author and put only the featured image. And like this it works.
Thanks for the time you spent for me. Maybe I will check better in future.
Thanks,
Bye
If you’re happy I’m happy 🙂
BTW, another possible cause would be what rwmb_get_value() is doing with author users. If its return value is empty for any reason custom columns in the list table would appear to not work.