Add a spinner to a submit button for slow forms

If you have a form that is slow to submit, this is a simple way to replace the submit button with a spinner. You may need to change the two selectors in the Javascript to be more specific, or different. Border-color may also want to be different, that’s the color of the spinner. <script>document.querySelector(‘form’).addEventListener(‘submit’,function(){ document.querySelector(‘[type=submit]’).className+=’ […]

Delete Wordpress post revisions older than x days

Delete post revisions older than 10 days: DELETE FROM wp_posts WHERE post_type = ‘revision’ AND post_modified_gmt < DATE_SUB(NOW(), INTERVAL 10 DAY) Delete post revisions older than 2 months: DELETE FROM wp_posts WHERE post_type = 'revision' AND post_modified_gmt < DATE_SUB(NOW(), INTERVAL 2 MONTH)

Quickly get rewrite rules for all wordpress posts

Run this SQL command (using adminer or whatever) and you’ll get a list of mod_rewrite rules ready to paste into your .htaccess file. SELECT CONCAT(‘RewriteRule ^’, post_name, ‘ https://yoururl.com/’, post_name, ‘/ [R=301,L]’) as ‘RewriteEngine On’ FROM `wp_posts` WHERE `post_type` = ‘post’ AND `post_status` = ‘publish’ ORDER BY `post_name` Change ‘post’ to ‘page’ if you want […]