Hi,
thanks for your post, and sorry for the trouble.
The reason for this likely is that either your script is not setting the visibility information correct (which is stored in the wp_postmeta DB table), or that something is broken with that DB table.
I therefore suggest that you don’t directly edit the table data by manipulating the JSON data in the database, but that you instead use the TablePress functions for this, like TablePress::$model_table->load() and ->save().
Regards,
Tobias
Thread Starter
Rub3X
(@rub3x)
Ah I see why it does it. I created the table manually with the default 5 rows 5 columns or whatever it is. Then when my script populates the table it doesn’t add the additional 1s for each new row in post_meta. So the table itself has 50 rows while there’s only five 1s set in post_meta. So when you click save it must see there’s more rows in the table than there are in post_meta and flips them all to 0 by default.
By chance is there just a way to disable the show/hide row feature within the plugin?
Hi,
yes, that’s exactly the reason. When modifying the table data, you will have to change the visibility as well. Something quick like https://github.com/TobiasBg/TablePress/blob/6b04e07a9c8c6e0d4262b7415f3d8c7ed28c080e/controllers/controller-admin.php#L1351 might do it.
Turning off the functionality is not directly possible. You could however override the settings on the “Edit” screen. That is, a user would still be able to mark rows/columns as hidden, and they would appear with the red background color there, but TablePress would ignore that and still show all rows/columns. For that, you could hook into a filter and set all rows/columns to visible, e.g. with
add_filter( 'tablepress_table_render_options', 'Rub3X_tablepress_show_all_cells', 10, 2 );
function Rub3X_tablepress_show_all_cells( $render_options, $table ) {
$render_options['show_rows'] = 'all';
$render_options['show_columns'] = 'all';
return $render_options;
}
This will basically set the show_rows and show_columns Shortcode parameters for all tables, as mentioned on https://tablepress.org/faq/documentation-shortcode-table/
Regards,
Tobias
Thread Starter
Rub3X
(@rub3x)
Thank you, and thanks for your dedication to the community 🙂
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Best wishes,
Tobias
P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!