Home > Net >  Wordpress Get the same meta
Wordpress Get the same meta

Time:05-15

i have problem about get post meta , i want to show meta by per user , but when i addet meta user_id i cant get all some meta

My code is

<?php 


    $post_id = get_the_ID(); 
    $current_user = wp_get_current_user(); 
    
    
  // when many users add meta in post
  update_post_meta( $post_id , 'meta'.$current_user , 'value'.$current_user); 
  
  
i want like it
 meta          value
user 1        test 1
user 2        test 2
user 3        test 3
& more ...



 

CodePudding user response:

Try this one:

<?php
$post_id = get_the_ID(); 
$users = get_users( array( 'fields' => array( 'ID' ) ) );
foreach($users as $user){
 get_post_meta($post_id , 'meta'.$user->ID ,true);
}
?>
  • Related