What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?

You can also do it this way – plugin free. Open phpmyadmin, browse over to your wp_posts table and: SELECT * FROM `wp_posts` WHERE post_type=”revision”; to see all the posts, their types and revisions and delete from `wp_posts` WHERE post_type=”revision” Though afraid at first…I did it. And it worked without any impact to the site.

Wacky taxonomy in wordpress

WordPress’ terms and taxonomies are spread over three tables in the database. Those tables are wp_terms, wp_term_relationships and wp_term_taxonomy – see the codex article on Database Description for more details. The parent relationship is part of the wp_term_taxonomy table, so you should inspect the differences between your environments in this table. wp_terms does not store … Read more

Insert Query not working in the form

I figured out my error in the query, Thank you all guys for responding, I just gave the piece of code <?php global $wpdb; $contactus_table = $wpdb->prefix.”contactus”; //error with the query $sql = “INSERT INTO $contactus_table (firstname, lastname, email, query, reg_date) VALUES (‘$firstName’, ‘$lastName’, ‘$email’, ‘$query’, CURRENT_TIMESTAMP)”; if($wpdb->query($sql)) { $BlogName = get_bloginfo(); echo $BlogName; } … Read more

WordPress site URL changed; how to fix it without database access?

See Changing The Site URL « WordPress Codex for recovery instructions on how to reset the URLs without database access, i.e. by editing either the wp-config.php file or the theme’s functions.php file with FTP: 1) by adding lines to wp-config.php (which can be left in place): define(‘WP_HOME’,’http://example.com’); define(‘WP_SITEURL’,’http://example.com’); 2) or the theme’s functions.php file (but … Read more

What’s the proper way to sanitize checkbox value sent to the database

I would use the filter_var() function. It has some predefined filters that you can use depending on what kind of data you are expecting such as string, number, etc. So to sanitize for a number: $sanitizedNum = filter_var($yourVar, FILTER_SANITIZE_NUMBER_INT); For a string you would just change “_NUM_INT” to “_STRING”. Wrap those in a custom function … Read more

Change options table prefix only

This is actually not that hard, but you will have to excuse me for keeping it high level because this is just a stupid thing to do as all things which are security by obscurity. All you need to do is write your WPDB driver, which inherits the WPDB class. Place it in /wp-content/db.php file … Read more

Creating a CSV with PHP inside the plugin directory

If you plan to write to a pugin folder since you used fopen, fwite, flose you are using the wrong function: File: wp-includes/link-template.php 3189: /** 3190: * Retrieves a URL within the plugins or mu-plugins directory. 3191: * 3192: * Defaults to the plugins directory URL if no arguments are supplied. 3193: * 3194: * … Read more