Advanced Custom Fields (ACF) x TablePress Extra CSS Classes
-
Hello there,
We have made the integration between ACF and TablePress mentioned on this link. However, is there a way to make this integration import the “Extra CSS Classes” specified on the table?
Here’s my code:
<?php $tables = get_sub_field( 'table' ); if( $tables ) : foreach( $tables as $post ) : $table = json_decode( $post -> post_content ); $table_header = array_shift( $table ); /* Using Tablepress with ACF in page templates http://ww.wp.xz.cn/support/topic/using-tablepress-with-acf-in-page-templates */ // Tablepress plugin query / args // Get ACF saved data $post_obj = get_sub_field( 'table' ); // Get the post-table pair json data $table_json = get_option( 'tablepress_tables' ); // JSON decode to array $json_dec = json_decode( $table_json, true ); // Get the pair data $post_table = $json_dec['table_post']; // Flip the key/value of the array $flip = array_flip( $post_table ); // Flip the key value pair to get the table ID from the post ID $table_id = $flip[$post->ID]; // Table args $args = array( 'id' => $table_id, 'use_datatables' => true, 'extra_css_classes' => 'table-records' ); ?> <?php tablepress_print_table( $args ); ?> <?php endforeach; // Reset data from post object wp_reset_postdata(); endif; ?>On the code above you see that we have a custom CSS class in the table args set as “table-records”. Now, instead of having this class hard coded, is it possible to dynamically pull the class specified on the back end of WordPress admin while editing the table?
https://www.dropbox.com/s/yu37q2m4h9k12vv/Screenshot%202018-01-11%2017.40.48.png?dl=0
Thank you!
The page I need help with: [log in to see the link]
The topic ‘Advanced Custom Fields (ACF) x TablePress Extra CSS Classes’ is closed to new replies.