Hi,
thanks for your post, and sorry for the trouble.
You are using the wrong post type. TablePress uses tablepress_table, so that your query should be
$args = array(
'post_type' => 'tablepress_table',
'posts_per_page' => -1,
);
$table_query = new WP_Query( $args );
Now, could you elaborate what you are trying to achieve? It’s usually not a good idea to directly query tables like this. Instead, it’s better to use e.g.
$table_ids = TablePress::$model_table->load_all();
foreach ( $table_ids as $table_id ) {
$table = TablePress::$model_table->load( $table_id );
// Do something with $table.
}
Regards,
Tobias
Thread Starter
Bogdan
(@bogdanguenther)
Ho Tobias,
Thank for for the fast help! I just need to get all TablePress tables in order to search for the specific Shortcode and so check where the tables are used.
I think for this simple action the directly query is safe to use?
Thanks,
Bogdan
Hi,
yes, you could then use a query, but the wp_posts table does not contain the table IDs, which you need for the Shortcodes.
I suggest that you take a look at the posts_search_filter() function in the controller-frontend.php class to see how TablePress searches for Shortcodes.
Regards,
Tobias
Thread Starter
Bogdan
(@bogdanguenther)
Hi Tobias,
> yes, you could then use a query, but the wp_posts table does not
> contain the table IDs, which you need for the Shortcodes.
Yes I noticed this fact already myself, I am using the code you suggested now, thank you!
> I suggest that you take a look at the posts_search_filter() function in the controller-
> frontend.php class to see how TablePress searches for Shortcodes.
Thank’s for the tipp, I have a simpler yet more specific attempt.
Bogdan
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Best wishes,
Tobias