WP Optimization: Removing Orphaned wp_options (especially the autoload ones)

Do you have access to a SQL client program like phpmyadmin or something similar? If so give this query SELECT option_id, option_name, LENGTH(option_value) FROM wp_options WHERE autoload = ‘yes’ AND option_name NOT LIKE ‘_transient%’ ORDER BY 3 DESC LIMIT 20; You’ll see the top twenty auto loaded options in descending order of length. Eyeball the … Read more

Fetch all Posts where logged in user has commented

It should be simple since comments are stored with a user_id if they are created by a logged in user and if not then its set to false so all you need to do is select the post id from comments that are made by user_id bigger the zero, something like this: function get_posts_with_loogedin_user_comments(){ global … Read more

posts_where Fails with More than One Custom Field in Query

Think about your query. You are asking that $wpdb->postmeta.meta_key be both “foo” and “bar”. That will never happen. If you ran this in a context where you’d get to read MySQL debugging data (PhpMyAdmin’s SQL console will do this) you would probably see a warning about an “impossible where clause”. You need to JOIN on … Read more

$wpdb get_var issue

I’ll guess that $wpdb->specials isn’t giving you what you expect. custom tables have to referenced like $wpdb->prefix . ‘specials’

Update user_login, user_nicename, and display_name

You don’t need SQL, and shouldn’t use it when Core functions will do the job. Part of the reason why is the complexity of the tables (and the fact they might change). Query your users, loop through pulling metadata, and update Proof of concept: $u = new WP_User_Query( array( ‘role’ => ‘customer’ ) ); foreach … Read more

Cron While Editing Post

It seems to have solved by changing the two functions, by taking a different approach: /* CHECK IF CURRENT USER IS NOT IN POST.PHP AND IN POST-NEW.PHP AND DOWNGRADE PUBLISH POSTS IN PENDING AFTER X DAYS */ if(is_admin() ) {global $pagenow; if( ‘post.php’ != $pagenow || ‘post-new.php’ != $pagenow) { add_action( ‘init’, ‘downgrade_publish_posts’ ); function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)