Echo name from custom field wordpress

I have a while loop that fetch me all the posts in a specific category,
Now I have add the custom values but the problem is that it only echo out the value of the custom field and not the name,

The function i use for printing out the value is

Read More
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    the_meta();
<?php endwhile; endif;?>

Now I have tried to echo out the get_post_custom_keys($post->ID);
but that only gives me the output "array"

I also tried a foreach loop, but it only gave me the name of the last post

$meta_key_used = get_post_custom_keys($post->ID); 
foreach ($meta_key_used as $meta_key) {
echo $meta_key;

Any ideas on how to print out the name of the custom field ?

Related posts

Leave a Reply

1 comment

  1. If you have all the post IDs that you want to call it for, then you could do this…

    $post_ids = array(1, 2, 3, 4, 5);  // for example
    
    foreach ($post_ids as $post_id)
    {
      $meta_key_used = get_post_custom_keys($post_id); 
    
      echo "Custom key names for post " . $post_id . "...<br />";
    
      foreach ($meta_key_used as $array_key => $meta_key_name)
      {
        $namet = trim($meta_key_name);
    
        if ('_' == $namet{0})    // ignore wp internal keys
          continue; 
    
        echo $array_key . " => " . $meta_key_name . "<br />";
      }
    }
    

    This excludes any WordPress internal keys where the value begins with an underscore.