List users with the most posts in the last 30 days

Here is what you need. <?php $date = new DateTime(‘NOW’); $date->sub(new DateInterval(‘P30D’)); //30 Days Interval echo $back30days= $date->format(‘Y-m-d H:i:s’) . “\n”; global $wpdp; $top_users = $wpdb->get_results(“select count(users.user_nicename) as posts, users.user_nicename as user_name from $wpdb->users as users join $wpdb->posts as posts where users.ID = posts.post_author AND posts.post_status=”publish” AND posts.post_date_gmt > ‘$back30days’ GROUP BY users.user_nicename ORDER BY … Read more

How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category

Addition note and warning: always always always take backups before doing anything in your database. It’s very easy to do something you didn’t mean to and lose tons of data, especially when dealing with DELETE statements. Also, if your database is using InnoDB for the database engine, you can use transactions via BEGIN, ROLLBACK, and … Read more

phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’

From what I can see, you are inserting data in table wp_commentmeta. However the column meta_id has a Primary Key restriction. You can see the table definition at http://codex.wordpress.org/Database_Description#Table:_wp_commentmeta As meta_id has a Primary Key restriction, this column may only hold unique values. The insert statements you have posted show only unique values for meta_id, … Read more

SELECT SQL_CALC_FOUND_ROWS with wordpress search

As discussed in the comments, your database prefix settings are off-kilter. Check the database prefix actually in use in your database, and make sure it’s the same as the one in wp-config.php. Also make sure all of your WordPress-related tables have the same prefix. You’ll also need to search through your database, particularly in the … Read more

Changing the entire permalink

So for the case where you want to change “lesson” to “learn”, there’s actually a “rewrite” option you could use, if you were the one registering the new post type. Since you are not, however, you have to be a little bit more crafty. Thankfully, WP gives you a hook to modify the post registration … Read more