What is the correct way to search 3 custom fields only in WordPress?

Are you using Advanced Custom Fields?(ACF?). Relevanssi is a really good plugin which increases the scope of the core WordPress search. Here’s the link: https://wordpress.org/plugins/relevanssi/ It allows users to search for posts via ACF fields attached to them. Once you install the plugin, you can use the following code in your functions.php file to instruct … Read more

wpdb replace returning 1 where delete and insert is expected

I have found here that; It is possible that in the case of a duplicate-key error, a storage engine may perform the REPLACE as an update rather than a delete plus insert, but the semantics are the same. Which would return 1 row affected on what should otherwise be a delete and insert. I am … Read more

og:image functions.php

Use var_dump($ogimage); to understand the contents of $ogimage presumably it’s returning an array of records from the database. Generally you would retrieve post meta values with get_post_meta WordPress Docs for get_post_meta() Also there are plugins that sort out the og tags for you such as Yoast SEO Yoast SEO plugin page on WordPress site

How to search usermeta table

This works: $WhoIsUser = get_users( array( ‘meta_key’ => ‘deviceid’, ‘meta_value’ => ‘45545’ ) ); This returns the whole row for that user from the users table. If you print_r it out like so: echo ‘<pre>’ echo print_r($WhoIsUser, TRUE); echo ‘</pre>’ you get: Array ( [0] => WP_User Object ( [data] => stdClass Object ( [ID] … Read more

Check if Value Exists in Database, adding row details to variables and echoing result

Thanks @user141080 I had the table_name declared wrong. I also missing the ” around the ‘$postcode’, which you do by adding an extra ‘at the end of the where clause and .”‘” after the variable. The code below works now. <?php /*————————————————-*/ /*————-Check Postcode —————–*/ /*————————————————-*/ global $wpdb; $table_name = $wpdb->prefix.’vw_postcode_checker’; if (!empty($_POST[postcode])) { $postcode … Read more

Delete oldest wordpress post (SQL query)

I figured it out! Pretty simple actually.. You can replace post_date_gmt with ID depending on your needs. post_author != 1 will prevent the admin’s post from being deleted, so the menu links and pages will stay intact 🙂 function deleteOldestPost(){ global $wpdb; $prefix = $wpdb->prefix; $wpdb->query(“DELETE FROM “.$prefix.”posts where post_author != 1 order by post_date_gmt … Read more

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