Sometimes, you may have useful data stored in your website’s database, like product details, event registrations or other information, and you want to show it directly to your visitors. By displaying data from the database directly, you can present dynamic content in an organised manner without manually updating it.
With the Table widget from The Plus Addons for Elementor, you can easily show the database entries in a table using a SQL query.
To check the complete feature overview documentation of The Plus Addons for Elementor Table widget, click here.
Requirement – This widget is a part of The Plus Addons for Elementor, make sure it’s installed & activated to enjoy all its powers.
To do that, add the Table widget from The Plus Addons for Elementor to the page and follow the steps –
1. Select SQL Query from the Content Table dropdown.
Note: Make sure you’ve enabled the SQL Query toggle from the Table Features popup to see the option.
2. Then, in the SQL Query field, you have to add your SQL query.
For example, if we add this query
SELECT ID, post_title, post_date FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post' LIMIT 10;
This will show the first 10 published blog posts from the wp_posts table, displaying each post’s ID, title, and publish date in the table.
You can use ${prefix} as a placeholder for the WordPress core tables so it matches your site’s table prefix.
For example, if you are using a different prefix like “mywp_” instead of the default “wp_”, then “${prefix}posts” will automatically become “mywp_posts”.
Note: You can’t show data from the user table.
But for custom tables, you have to use the actual table name.
From the Refresh Time dropdown, you can select how often new data will be pulled from that particular database table.
But if you want to pull fresh data from that particular database table before that specific time, you can click the Delete button in the Delete All Transient section. This will delete the existing data and add new data from that particular database table.
So this is how easily you can show data from the database in a table.