Can’t get expected result from a wpdb query

I know I probably can’t see the full picture, but in the excerpt you provided isn’t globalizing $post. global $wpdb, $post; $short = $wpdb->get_var(“SELECT url FROM $wpdb->prefix.’tweet_url’ WHERE post_id = ‘$post->ID’ “);

Using $wpdb to update current post

Nevermind, I was complicating this whole process because I wasn’t thinking about just using get_post_meta(). add_action(‘draft_to_publish’,’gcpl_draft_to_published’); function gcpl_draft_to_published($post){ $exp_processed = get_post_meta($post->ID, ‘_expiration-date-processed’, true); // check if the custom field has a value if($exp_processed != ”) { delete_post_meta($post->ID, ‘_expiration-date-processed’); } }

Insert Extra fields added in the front end registration form to DB

Why the downvotes for using user meta? That’s how I do it, I store all the extra profile stuff in wp_usermeta table by utilizing update_user_meta. <?php // first validate all $_POST data $validated = $this->validate_and_sanitize(); $username = $validated[‘uname’]; $password = $validated[‘pass’]; $email = $validated[’email’]; $new_user_id = wp_create_user($username, $password, $email); if ( is_wp_error($new_user_id) && array_key_exists(‘existing_user_login’, $new_user_id->errors)) … Read more

Mysql query and odd results

You have to enclose the OR part to brackets: $sql = “SELECT ID,post_title,post_content,post_date,post_type FROM {$wpdb->posts} WHERE (post_content LIKE {$stuff}) AND post_status=”publish” AND post_type=”{$post_type}” AND ID != {$post->ID} LIMIT {$limit}”; $results= $wpdb->get_results($sql); Try this one: SELECT ID,post_title,post_content,post_date,post_type FROM wp_posts WHERE (post_content LIKE ‘%Battery%’ OR post_content LIKE ‘%Watcher%’ OR post_content LIKE ‘%Widget%’ OR post_content LIKE ‘%matches%’ OR … Read more

Create Table Failed Column Date DateType

Well, after looking at the other tables I had created successfully, only difference was the description column. Apparently WordPress or MySQL doesn’t like that as a column name and somehow has it reserved. So, after renaming it, the table was created fine. Hope this helps someone else in the same boat.

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