Is a MySQL DATETIME or TIMESTAMP value retrieved through $wpdb in UTC?

Summary: WordPress does run date_default_timezone_set( ‘UTC’ );. It does have a timezone option modifiable by the admins and retrieved using get_option( ‘timezone_string’ ). However, none of that has any effect on the query run through $wpdb. You should get the same results from $wpdb as if you had run the MySQL query without WordPress. Details … Read more

How to get the post_id from postmeta

There’s the WordPress meta API for retrieving meta values from the wp_postmeta table, but the API doesn’t provide a function for retrieving the post ID (post_id value), but you can use custom SQL as in your code. However, $wpdb->get_col() returns an array of values (upon success), so that’s why you get the “Array” when you … Read more

WordPress Query is taking more then 20 second and stuck on creating index

Looking at your query, I see lots of stuff like wp_posts.post_content LIKE ‘%اهمية%’. You should know that column LIKE ‘%matchstring%’ is a notorious MySQL performance-killer. If you can change your operations to use column LIKE ‘matchstring%’ (with no leading %) this will get better. Or, maybe it makes sense for you to adopt a search … Read more

Help running a MySQL query to update all wp_#_options tables in a Multisite install

Got a partial solution, but requires VPS to run it as shared hosting has a restriction on what you can do with a cursor. Anyway, DROP PROCEDURE IF EXISTS `update_all_options`; DELIMITER // CREATE PROCEDURE update_all_options( IN db varchar(255), IN theoption varchar(255), IN set_val VARCHAR(255) ) BEGIN DECLARE table_val VARCHAR(255); — Declare variables used just for … Read more

Tons of Twitter rows in my database

Here is a bait-and-switch approach to deleting all those rows: CREATE TABLE wp_posts_new LIKE wp_posts; ALTER TABLE wp_posts_new DISABLE KEYS; INSERT INTO wp_posts_new SELECT * FROM wp_posts WHERE post_type’http’ AND post_title<>’GET http://twitter.com/statuses/user_timeline/@xcentric.json?count=100′; ALTER TABLE wp_posts_new ENABLE KEYS; ALTER TABLE wp_posts RENAME wp_posts_old; ALTER TABLE wp_posts_new RENAME wp_posts; Now start using you website. When you are … Read more