Title: Using get_post_custom_values
Last modified: August 19, 2016

---

# Using get_post_custom_values

 *  [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * (@thorhammer)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/using-get_post_custom_values/)
 * Hi there.
 * I am trying to build a function in my theme which collects post metadata and 
   displays them, according to what I write in the custom field. I want to show 
   images representing flags (for countries). Some posts must have more than one
   flag displayed.
    I thought the function get_post_custom_values would be nice.
 * <?php get_post_custom_values($key, $post_id); ?> in my theme where I want the
   images to show up. For each post I create a custom field named flags, and type
   in values like uk,dk (etc).
 * And this script to associate metadata to images:
 * <? php
    $uk=/images/uk-png; $dk=/images/denmark.png;
 * $mykey_values = get_post_custom_values(‘flags’);
    Foreach ($mykey_values as $
   key => $value) { echo “$key => $value (‘flags’)”; } ?>
 * But it doesnt work. Any hints?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * (@thorhammer)
 * [17 years ago](https://wordpress.org/support/topic/using-get_post_custom_values/#post-1179871)
 * bump..?
 *  Thread Starter [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * (@thorhammer)
 * [17 years ago](https://wordpress.org/support/topic/using-get_post_custom_values/#post-1179888)
 * Never mind, I found a solution.
 *     ```
       ?php $languages=get_post_meta($post->ID,"languages",false); ?>
       <?php foreach($languages as $language) {
       echo "<img src=\"".$language."\" />
       ```
   
 * The only down thing is that I have to enter a custom field “languages” several
   times with the full URL-path to the images. But, it works, and I am happy. Hope
   someone else in need of using custom fields are reading this short post.

Viewing 2 replies - 1 through 2 (of 2 total)

 The topic ‘Using get_post_custom_values’ is closed to new replies.

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [metadata](https://wordpress.org/support/topic-tag/metadata/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/using-get_post_custom_values/#post-1179888)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
