Title: Table ID from Post ID
Last modified: August 22, 2016

---

# Table ID from Post ID

 *  Resolved [bdjenkin](https://wordpress.org/support/users/bdjenkin/)
 * (@bdjenkin)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/)
 * Hi,
 * I am trying to integrate the tables to display in search results. My question,
   is it possible to get the table ID from a post ID passed in a url
    `?post_type
   =tablepress_table&p=1030` My plan is to then use `tablepress_print_table ()` 
   to print the table in the results. This would really help me out, thanks.
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278255)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * TablePress does integrate into the WordPress search already, actually, i.e. all
   tables that are embedded (with their Shortcode) into a post or page, will be 
   searched.
 * Regardless, you could maybe use the information in the `tablepress_tables` option(
   that you can load with `get_option()`). That contains an array with the table
   ID in the key and the post ID in the value.
 * Regards,
    Tobias
 *  Thread Starter [bdjenkin](https://wordpress.org/support/users/bdjenkin/)
 * (@bdjenkin)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278260)
 * Hi Tobias,
 * Thanks for the quick response. I should have been more specific, I am using openSearchServer
   to index my site and the coordinating WP plugin to modify standard search. The
   URL snippet I posted before was the URL field from the oss-results, my plan is
   to print table as described in place of the oss generated content:
    [[“Click 
   in this area to sort these files”],[“Accidental Hazardous Exposure”],[“Adverse
   Reaction Investigation Report”],[“Authorization Form “],[“Authorization Form (
   Spanish)”],[“Activity- IEB Eye Tissue Recovery”],[” Activity – Procurement “],[”
   Activity- Transport”],[“Attention Pickup…
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278264)
 * Hi,
 * ah, ok, I see.
    Yes, then extracting the table ID from the post ID might be the
   best option.
 * Regards,
    Tobias
 *  Thread Starter [bdjenkin](https://wordpress.org/support/users/bdjenkin/)
 * (@bdjenkin)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278266)
 * Thanks, just to clarify: do I call `get_option()` on the post_id?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278267)
 * Hi,
 * no, you use
 *     ```
       (array) json_decode( get_option( 'tablepress_tables' ), true );
       ```
   
 * to get an array that contains the table ID to post ID relationship.
 * Regards,
    Tobias
 *  Thread Starter [bdjenkin](https://wordpress.org/support/users/bdjenkin/)
 * (@bdjenkin)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278297)
 * You are amazing! I got the search to display tables directly in the results. 
   The only problem I have now is that I’m passing `id=$table_id&use_datatables=
   true&print_name=false` to `tablepress_print_table` but it still prints the table
   name… Any idea why that would happen?
 *  Thread Starter [bdjenkin](https://wordpress.org/support/users/bdjenkin/)
 * (@bdjenkin)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278320)
 * Also, and I’m sorry if this is annoying you, it would great if there were a way
   to pass a parameter through `tablepress_print_table` that would pass to the table’s
   search field. That way I could narrow down the table’s contents to the term searched.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278446)
 * Hi,
 * good to hear that this is working!
    Instead of using the string parameter, I 
   suggest to use the array version, which is more flexible and easier to read:
 *     ```
       tablepress_print_table( array(
         'id' = > $table_id,
         'print_name' => false,
         'use_datatables' => true,
       ) );
       ```
   
 * I’m not sure about the table name though. Are you sure that that’s coming from
   the plugin and not maybe because it’s written above the Shortcode as text? Also,
   you should not really need those Shortcode parameters, if the corresponding checkboxes
   are set on the tables’s “Edit” screens.
 * Regarding that filter parameter: You could use this TablePress Extension to only
   show the matching rows: [http://tablepress.org/extensions/row-filter/](http://tablepress.org/extensions/row-filter/)
   
   Or, you could use this one [http://tablepress.org/extensions/datatables-auto-filter/](http://tablepress.org/extensions/datatables-auto-filter/)
   to use the JS-based search.
 * Regards,
    Tobias
 * Regards,
    Tobias
 *  Thread Starter [bdjenkin](https://wordpress.org/support/users/bdjenkin/)
 * (@bdjenkin)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278475)
 * I’m all set now, thank you again for help.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278524)
 * 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](https://wordpress.org/support/view/plugin-reviews/tablepress)
   here in the plugin directory. Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Table ID from Post ID’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/table-id-from-post-id/#post-5278524)
 * Status: resolved