Support » Plugin: TablePress - Tables in WordPress made easy » Select Input of All Tables

  • Resolved Mark Wilkinson

    (@wpmarkuk)


    I want to generate a select input (drop down) of all tables with the values as their IDs. When I first looked at this each table also has a post (saved as a post in the custom post type tablepress_table) however the table is not actually stored with the post.

    Therefore I either need to able to get a list of all tables with their values as the table IDs or how can I get a table ID from its post ID.

    I see that the associated on posts and tables is stored in the options table as tablepress_tables. However when I get that options it just returns a string like so:

    string(36) "{"last_id":2,"table_post":{"1":118}}"

    I would have expected an array. How can I use this to get the table ID from the post ID please. You help is much appreciated.

    https://wordpress.org/plugins/tablepress/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Mark Wilkinson

    (@wpmarkuk)

    It seems as though I have now found the answer (I did search originally – promise!). This support ticket outlines the solution:

    http://wordpress.org/support/topic/map-table-id-to-post-id?replies=3

    I was neglected to json_decode.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Yes, you will need a json_decode() there. The better way might be to use a TablePress function directly, which handles all the internal stuff:

    $table_ids = TablePress::$model_table->load_all();

    That will directly give you the array of table IDs.

    Regards,
    Tobias

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Select Input of All Tables’ is closed to new replies.