Add the following code in the functions.php
for acf
function get_all_meta($type){
global $wpdb;
$result = $wpdb->get_results($wpdb->prepare(
"SELECT post_id,meta_key,meta_value FROM wp_posts,wp_postmeta WHERE post_type = %s
AND wp_posts.ID = wp_postmeta.post_id", $type
), ARRAY_A);
return $result;
}
function acf(){
$options = array();
$acf = get_all_meta('acf');
foreach($acf as $key => $value){
$options['post_type'][$value['post_id']]['post_id'] = $value['post_id'];
$test = substr($value['meta_key'], 0, 6);
if($test === 'field_'){
$post_types = maybe_unserialize( $value['meta_value'] );
$options['post_type'][$value['post_id']]['key'][] = $post_types['key'];
$options['post_type'][$value['post_id']]['key'][] = $post_types['name'];
$options['post_type'][$value['post_id']]['key'][] = $post_types['type'];
}
if($value['meta_key'] == 'rule'){
$post_types = maybe_unserialize( $value['meta_value'] );
$options['post_type'][$value['post_id']]['post_types'] = $post_types['value'];
}
}
return $options;
}
This will give you the array value of post meta key for acf.
How to use
foreach(acf() as $key => $value){
update_post_meta(76, $value['type'], 'Steve');
}
For pods
function pods(){
global $wpdb;
//get the pods post types id.
$result = $wpdb->get_results($wpdb->prepare(
"SELECT ID,post_title,post_parent FROM wp_posts WHERE post_type = %s", $type
), ARRAY_A);
// pods each field for a post type create separate post type so again query to get the field post type result.
$pods_field_post_type = array();
foreach($result as $value){
$pods_field_post_type = $wpdb->get_results($wpdb->prepare(
"SELECT ID,post_title,post_name FROM wp_posts WHERE post_type = %s
AND post_parent = %d
", '_pods_field',$value["ID"]
), ARRAY_A);
}
$fields = array();
foreach($pods_field_post_type as key => $value):
$podsAPI = new PodsAPI();
$pod = $podsAPI->load_pod( array( 'name' => '
post' ));
$fields[] = $pod['fields'][$value['post_name']]['type'];
endforeach;
}
print_r($fields);
How to use
foreach($fields as $key => $value){
update_post_meta(76, $value, 'Steve');
}
function acf() and pods() give you the exact meta key of that post type.
If you copy and paste the code it may not work.
Hope this answer help you and also others.
let me know you not trouble anything.