Articles of database

Adding custom field and querying from post table

I’ve been trying to figure this out for a while now. So I’m trying to add a custom field call “counter” to every single post. I try simply inserting the field “counter” to the post table. Every time a user clicks a button on the post, it increments the counter So far so good. But […]

PHP variable in WordPress database query

When running the following code : $voucher = ‘MK0186′; $is_in_database = $wpdb->get_results( “SELECT * FROM my_codes_table WHERE code =” . $voucher ); I get : WordPress database error: [Unknown column ‘MK0186’ in ‘where clause’]. I don’t understand why.

Is database deleted on clicking “reinstall” button in WordPress updates?

I have a blog made with WordPress. If I click “Re-install” button present in WordPress updates page, will all the database be dropped and created again? Will my posts be deleted?

Import External XML

I don’t know where to start with this one. I would like to create custom post type which will list properties on clients website. I would like those properties being feed from another website/software. So other website/software will be sending XML file to my WordPress site and I would like to receive that file and […]

Locking one blog of many in a multi user/blog WordPress installation

I have a multi user /wordpress installation that is working fine. One of the blogs running on that multi user /wordpress installation will never be updated again but I want it there for historic reasons. Is it possible to make one blog read-only even though it is on a multi user /wordpress installation and sharing […]

Get a custom table to an array

How can I take my table I created like this: global $wpdb; //Get all the wordpress database stuff $table_prefix = $wpdb->base_prefix; //Get the global prefix for all sites (on a multisite installation) $table_name = $table_prefix.’wpaa’;//Add wpaa behind the prefix $sql = “CREATE TABLE IF NOT EXISTS `”.$table_name.”` (….) “; //Create table and its rows. (Rows […]

How do I display offsite database info on my wordpress site?

I host some online games from my personal computer which the game saves information to my Mysql database. I would like to display live data (if possible) on my hosted WordPress site. I know the easiest way would to do a remote connection, but my host does not allow that. All I am trying to […]

How safe is it to delete old posts edits to save database space?

After this question: There is an answer that suggests deleting past edits directly from database, which would be nice, because I could create queries to delete specific edits only. But, Is this safe? Why?

Best practice to limit results in get_row()?

This is my query to check if a title exists (it’s in a loop, therefore [$i]). $wpdb->get_row(“SELECT * FROM wp_posts WHERE post_title = ‘” . $titles_arr[$i] . “‘”, ‘ARRAY_A’); Anyway, I would like to know how to use LIMIT 0,1000 to query only the last 1000 added posts to the database when using get_row() function. […]

How can I restrict php mail() to only send me one email after a db error

I’m in the process of customizing dp-error.php. I’m using the mail() function to alert me when there’s a database connection problem on my website. The trouble is, what if 1000 people visit my website when it’s down? Wouldn’t I get 1000 emails? Here’s the code I’m using to send email: mail(“”, “Database Error”, “There is […]