I want to retrieve data from custom table, that I’ve made inside the wordpress database and display it in a wordpress page , like posts
Thanks in advance
I want to retrieve data from custom table, that I’ve made inside the wordpress database and display it in a wordpress page , like posts
Thanks in advance
You must be logged in to post a comment.
Here is an example code that will get the data and then display it:
It’s good practice to use unique names for variables and functions, so you may want to add a unique prefix to all your variables or functions IE: ($prefix_table_name where “prefix” would be something unique such as the abbreviation of your theme or plugin.)
Reference – wpdb – codex
Please try this code for display all the records from database in wordpress. For this firstly need to create a file.php inside your selected wordpress folder and then use this file as a template. And this code will work perfectly Thank you all.
Sounds like you’re looking for
$wpdb
. You’ll need to write all your own functions and such. I strongly recommend sticking to the established naming conventions (stuff likethe_blah
andget_blah
, maybe with a prefix) for ease of readability and for consistency.Modification of @Kirill Fuchs’s answer. If you use this code on shortcode this may create a problem. It may display the outputs in wrong order. To avoid the I used return instead of echo. Try to do this on shortcode this way: