Skip to content

Instantly share code, notes, and snippets.

@emaildano
Created July 30, 2014 15:21
Show Gist options
  • Save emaildano/a84a46b43c622c269768 to your computer and use it in GitHub Desktop.
Save emaildano/a84a46b43c622c269768 to your computer and use it in GitHub Desktop.
<?php
// Layout Option: Table via Tablepress
// Init Post Object
$postobject = get_sub_field('table');
$post = $postobject;
setup_postdata( $post );
// 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 );
// table args
$args = array(
'id' => $flip[$post_obj->ID]
); ?>
<section>
<div class="tablepress table-responsive">
<?php
get_template_part('templates/page-text-styles/body-copy');
tablepress_print_table( $args);
?>
</div>
</section>
<?php // Reset data from Post Object
wp_reset_postdata(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment