Support

Account

Home Forums General Issues get_fields not returning a specific value Reply To: get_fields not returning a specific value

  • Hmmm, so I figured out the issue. It’s a little concerning to me, but perhaps it was because I was updating with names instead of keys. Perhaps making the change to keys will solve the issue.

    Basically, the database was confused 🙂

    I used this
    `
    public static function get_fields($id){
    global $wpdb;
    $rows = $wpdb->get_results(“SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id = $id AND meta_value LIKE ‘field_%'”);
    var_dump($rows);
    exit();
    }
    `

    And thought for a second that one of the keys looked familiar. If you look at the image above, you’ll see why it looked familiar….because the key that being returned for post 490 was the same key that was associated with 488. For a second, I thought maybe keys were just unique on posts, but then looking at the admin custom fields section keys, I realized that wasn’t the key at all that should be in the database for post 490. Somehow, ACF created a wrong entry for post 490 by using a field key that was not related to that post in any way.