I am using a php script in order to display the post images of my entries in the backend of WP.
Everything works fine , even Toolset views / Layout is shown correctly in the backend.
Only the Forms are not displayed (not even the title) when using this script.
So normaly I would say - just do not use the script, but it works with all the other entries of Toolset.
(sorry I am no programmer)
Here is the script I am using in the functions.php
// Add featured image column to admin panel - posts AND pages
// Add new column as second <em><u>hidden link</u></em>
function j0e_add_image_column($columns){
$columns = array(
'cb' => '<input type="checkbox">',
'j0e_image_thumb' => __('Image'),
'title' => __( 'Title' ),
'author' => __( 'Author' ),
'categories' => __( 'Categories' ),
'tags' => __( 'Tags' ),
'comments' => __( 'Comments' ),
'date' => __( 'Date' )
);
return $columns;
}
add_filter('manage_posts_columns', 'j0e_add_image_column', 5);
add_filter('manage_pages_columns', 'j0e_add_image_column', 5);
// Give the new column a value
function j0e_display_image_column($column_name, $post_id){
switch($column_name){
case 'j0e_image_thumb':
$post_thumbnail_id = get_post_thumbnail_id($post_id);
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src( $post_thumbnail_id, 'thumbnail' );
echo '<img width="100" src="' . $post_thumbnail_img[0] . '">';
}
break;
}
}
add_action('manage_posts_custom_column', 'j0e_display_image_column', 5, 2);
add_action('manage_pages_custom_column', 'j0e_display_image_column', 5, 2);
// Format the column width with CSS
function j0e_add_admin_styles() {
echo '<style>.column-j0e_image_thumb {width: 100px;}</style>';
}
add_action('admin_head', 'j0e_add_admin_styles');
So do you have any idea what causes the form titles to not be displayed?
best regards
Michael
Hi Michael,
Thank you for contacting us and I'll be happy to assist.
To make sure that your custom code for the image column works for regular posts, but not the Toolset Forms (CRED), you'll need to wrap it inside a condition.
You can update the following function from:
function j0e_add_image_column($columns){
$columns = array(
'cb' => '<input type="checkbox">',
'j0e_image_thumb' => __('Image'),
'title' => __( 'Title' ),
'author' => __( 'Author' ),
'categories' => __( 'Categories' ),
'tags' => __( 'Tags' ),
'comments' => __( 'Comments' ),
'date' => __( 'Date' )
);
return $columns;
}
To:
function j0e_add_image_column($columns){
$screen = get_current_screen();
if ($screen->base == "edit") {
$columns = array(
'cb' => '<input type="checkbox">',
'j0e_image_thumb' => __('Image'),
'title' => __( 'Title' ),
'author' => __( 'Author' ),
'categories' => __( 'Categories' ),
'tags' => __( 'Tags' ),
'comments' => __( 'Comments' ),
'date' => __( 'Date' )
);
}
return $columns;
}
I hope this helps and please let me know how it goes.
regards,
Waqar
Works like a charm, right on the spot!
My issue is resolved now. Thank you!