WordPress TablePress Recovery

Someone tried to restore TablePress and ran into a problem not being able to find their old tables, which according to them were available in the WordPress backup they made. They asked me if I could fix it, let’s recovery those missing tables!

Preparation

First off I started a fresh WordPress setup to see how TablePress installs itself and if and where it ends up in the WordPress backup. I came to the following findings.

    o

  • TablePress tables are wp_posts entries with .
  • o

  • TablePress short code [table id=1 /] where 1 corresponds to a TablePress ID, NOT a wp_posts ID.
  • o

  • TablePress ID’s are stored as JSON string in: SELECT * FROM wp_options WHERE option_name = 'tablepress_tables'
  • o

  • The SELECT option_value FROM wp_options WHERE option_name = 'tablepress_tables' format is:

    Where last_id is the last modified table, and table_post is an array of TablePress ID’s (1,2,3) + wp_posts ID’s (1000,1200,1700)

Let’s recover!

A simple, manual solution to the problem was a simple query:

Let’s find all wp_posts entries with type ‘tablepress_table’ and check if there are revision posts.

This query could resulting in something like:

ID
2850
2721
2338
2002
1078

 

And now we simply grab those ID’s and create a new TablePress ID, wp_posts.ID json array, like this:

Where # stands for each ID (1078, 2002, …) from the previous query.

Hopefully this is useful for others! Please do check if all tables work properly, I had one table that got switched around for example.

Leave a Reply

Your email address will not be published. Required fields are marked *