Title: Randomize Custom Fields from Posts
Last modified: August 21, 2016

---

# Randomize Custom Fields from Posts

 *  Resolved [Archaic Radio](https://wordpress.org/support/users/archaic-radio/)
 * (@archaic-radio)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/randomize-custom-fields-from-posts/)
 * Hi Ya’ll,
 * I’m having a hard time getting my page to display a random list of custom fields
   from a specific post. Below is my code.
 *     ```
       <?php
       $digvaud_id = 1833;
       $digvaud_post = get_post($args,$digvaud_id);
       ?>
   
       <?php $itemnamefeat = get_post_meta ($digvaud_post->ID, 'wpcf-playlist-song-title', false); ?>
       <?php $itemmp3feat = get_post_meta ($digvaud_post->ID, 'wpcf-playlist-song-mp3', false); ?>
       <h3 class="playlist-title">Playlist</h3>
       <ul>
       <?php foreach (array_combine($itemnamefeat, $itemmp3feat) as $itemnamefeat => $itemmp3feat){
   
       $playlist_combinedfeat = '<li><a href="' .$itemmp3feat. '">' .$itemnamefeat. '</a></li>';
   
       echo apply_filters('the_content', $playlist_combinedfeat);
       } ?>
       </ul>
       ```
   
 * The result is currently a list of custom field values from post #1833. The only
   issue I’m having is randomizing the list. Thanks for any help.

Viewing 1 replies (of 1 total)

 *  Thread Starter [Archaic Radio](https://wordpress.org/support/users/archaic-radio/)
 * (@archaic-radio)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/randomize-custom-fields-from-posts/#post-4483884)
 * Turns out thee are about a thousand ways to do this. This is the way I ended 
   up using.
 *     ```
       <?php
       // The Query
       $my_query = new WP_Query( array(
       	'orderby' => 'rand',
       ));
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Randomize Custom Fields from Posts’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [post feed](https://wordpress.org/support/topic-tag/post-feed/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [random posts](https://wordpress.org/support/topic-tag/random-posts/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [Archaic Radio](https://wordpress.org/support/users/archaic-radio/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/randomize-custom-fields-from-posts/#post-4483884)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
