What should a WordPress developer know about MySQL? [closed]

Questions like this usually yield a lot of discussions, but let me give it a shot: If you’re talking about SQL queries: If you’re only adding content, managing plugins, themes and WordPress updates, there’s a 99.9% chance that you will never need to write a single line of it. I don’t want to put 100% … Read more

Code to remove authors with no posts connected to them

<?php /** * Plugin Name: Delete Non Authors */ function delete_non_authors() { global $wpdb; $non_authors = $wpdb->get_col( “SELECT DISTINCT $wpdb->users.ID FROM $wpdb->users LEFT JOIN $wpdb->posts ON $wpdb->users.ID = $wpdb->posts.post_author WHERE $wpdb->posts.ID IS NULL” ); foreach ($non_authors as $user_ID) wp_delete_user($user_ID); } register_activation_hook(__FILE__, ‘delete_non_authors’); ?> Drop this in a file, name it something like delete-non-authors.php, upload it … Read more

Connect to MySQL using Windows Authentication

This is just bad security method. Because the only way you can connect to the mysql database is via that pc you use. Where is if you username/pwd, you can move the site to another server, etc. So Windows Authentication is a bad idea, too easy to overcome, and honestly just not that secure. Where … Read more

Many slow queries post_type = ‘attachment’;

This is bug #31071: media / post_mime_type related queries are very slow on larger sites. It should have been fixed for version 4.8 now. You can try it on a test site that is a mirror of your production site. There are some very interesting ideas in that bug discussion. See if you can use … Read more

Paypal Post IPN handeling nightmare

I ended up using kind of a hack. I made a hidden field that was populated with the user ID. I then used this to update metas and what not on a successful IPN and or successful payment. Ie: add_filter(“gform_paypal_post_ipn”, “update_order_status”, 10, 4); function update_order_status($ipn_post, $entry, $config, $cancel){ // if the IPN was canceled, don’t … Read more

Site not responding error – taking long to load [closed]

You shouldn’t be blindly changing configs in my.cnf. Use rackerhacker/MySQLTuner-perl · GitHub to test and check your my.cnf configs. It will give suggestions for memory allocations and all other aspects of MySQL tuning. You also should configure httpd.conf for high loads. See Apache Performance Tuning – Apache HTTP Server

Replacing link URL ending strings via MySQL

DISCLAIMER : Not a WordPress Developer, Just a MySQL DBA For a given table, say link_url mysql> show create table wp_links\G *************************** 1. row *************************** Table: wp_links Create Table: CREATE TABLE `wp_links` ( `link_id` bigint(20) unsigned NOT NULL auto_increment, `link_url` varchar(255) NOT NULL default ”, `link_name` varchar(255) NOT NULL default ”, `link_image` varchar(255) NOT NULL … Read more

Separate DB by yearly archive of WordPress

I needed this for a client recently (he wanted to do the same but be able to create a archive by himself in the wordpress backend) and couldn’t find a good plugin for it. It’s pretty easy to custom code this actually. You just need to make your install a network install and then place … Read more