I can’t seem to figure out how to access custom WordPress database tables.

I have this sample code that I found online that’s supposed to count the number of rows in a table. Of course… It works, but when I created my own table using phpMyAdmin… It no longer works. What am i doing wrong?

I’m also wondering whey the “wp_users” table name dosen’t work, but “users” does..

My table name is “test” I’ve also tried “wp_test” but for some reason none of them work.

<?php

$user_count = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->users”);
echo “<p>User count is {$user_count}</p>”;

?>

FYI, I never use forums so forgive me if i’m not doing something right.

Read more here:: I can’t seem to figure out how to access custom WordPress database tables.

Leave a Reply

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