Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Hhm, that’s tricky, and I can’t really think of a quick solution here.
    The best way might be to write some custom PHP code that filters the table data, e.g. in the tablepress_table_render_data filter hook in the classes/class-render.php file.
    There, you could check the size of the array and then remove the unwanted columns.

    Regards,
    Tobias

    Thread Starter marketing guy

    (@el-terrible-bmw)

    Ok thanks again Tobias.

    I was able to figure it out. If anyone else is looking for a similar thing, you can just use this:

    add_filter( 'tablepress_table_render_data', 'tablepress_hide_colummns' );
    
    function tablepress_hide_colummns( $table ) {
    
    	$table_headers 	= $table['data'][0];
    	$total_columns 	= count($table_headers);
    	$table_data 	= $table['data'];
    
    	if ($total_columns == 8) {
    
    		// Loop through and delete columns 1 and 6
    		foreach ($table_data as &$row) {
    			unset($row[1]);
    			unset($row[6]);
    			$row = array_values($row);
    		}
    
    		$table['data'] = $table_data;
    
    	}
    
    	return $table;
    }
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    very cool! That’s exactly the solution that I had in mind here ??
    Thanks for sharing it!

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide specific column number’ is closed to new replies.