Support » Plugins and Hacks » WP-Table Reloaded » [Resolved] Custom Export for Table Contents

[Resolved] Custom Export for Table Contents

  • Hi,

    I’m trying to query two cells of a table for each post I have:


    What is the best way to query these two rows?

    Template Name: Table Export
    global $post;
    $args = array(
    	'numberposts' => 10,
    	'orderby' => 'post_title',
    	'order' => 'DESC',
    	'cat' => 1,
    	'post_status' => 'publish'
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) : setup_postdata($post); ?>
    $theContent =  get_the_content();
    $table_id = false;
    if (preg_match('/\[table\ id=(\d*).*\]/im', $theContent, $r)) {
    	if (isset($r[1])) {
    		$table_id = $r[1];
    <div><?php echo $theContent; ?> </div><br /><br />
    <strong>Table Name = <?php  wp_table_reloaded_print_table_info('id=' . $table_id . "&field=name" ); ?></strong><br />
    <strong>Author <?php  wp_table_reloaded_print_table_contents('id=' . $table_id . $row_1 ); ?></strong>
    <strong>Bio <?php  wp_table_reloaded_print_table_contents('id=' . $table_id . $row_2); ?></strong>
    <?php endforeach; ?>


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



    the best way for this would be to use the “hide_rows” and “show_rows” parameters. With that, your last two lines would become

    <strong>Author <?php  wp_table_reloaded_print_table('id=' . $table_id . '&hide_rows=all&show_rows=1' ); ?></strong>
    <strong>Bio <?php  wp_table_reloaded_print_table('id=' . $table_id . '&hide_rows=all&show_rows=2' ); ?></strong>

    Technically, this is going to create a HTML table with one row and one column, which is kind of ugly. Therefore, it might be worth to extract the relevant code from http://wordpress.org/support/topic/plugin-wp-table-reloaded-display-content-of-a-cell?replies=18 and to use that to just show the cell contents.

    Now, I have two more things:
    First: If you have just started implementing this with WP-Table Reloaded, I’d actually make a recommendation: Switch to the official and designated successor TablePress now ( http://wordpress.org/extend/plugins/tablepress/ ). This will save you some time when WP-Table Reloaded is being discontinued in favor of TablePress in the near future.
    Secondly: I’m actually not sure that your approach is a good one. From what I can see, you want to use WP-Table Reloaded as a database system, to get data of a clearly defined type (namely information about some person). I can imagine that this would be much better suited for implementation using WordPress Custom Post Types ( http://codex.wordpress.org/Post_Types ), so maybe that’s something that you should investigate. With that approach, each person would be a separate post of your new Custom Post Type.


    Hey Tobias,

    Thanks for the quick response. So, I tried to use your shortcode example in my code like so:

    Author = <?php do_shortcode('[table_cell c=1 r=1] id='. $table_id .' [/table_cell]') ?>

    What am I doing wrong or is there a better method to use that doesn’t use the shortcode?



    Hey Tobias,

    I tried making the updates to your function as well as hard coded a table id and I’m still not getting this.



    Plugin Author TobiasBg



    on first glance, everything in that pastie looks good.

    Does the [table_cell] Shortcode work in regular post content, i.e. when you insert it into a post or page directly?


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Custom Export for Table Contents’ is closed to new replies.
Skip to toolbar