Skip Navigation

[Resolved] CRED Form Titles vanish in Backend when using code in functions_php

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by michaelM-30 5 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1192971
forms- not ok.jpg
views-ok.jpg
post_image in backend.jpg

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

#1193026

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

#1193032

Works like a charm, right on the spot!

My issue is resolved now. Thank you!