[resolved] Randomize Custom Fields from Posts (2 posts)

  1. Archaic Radio
    Posted 1 year ago #

    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.

    $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>
    <?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);
    } ?>

    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.

  2. Archaic Radio
    Posted 1 year ago #

    Turns out thee are about a thousand ways to do this. This is the way I ended up using.

    // The Query
    $my_query = new WP_Query( array(
    	'orderby' => 'rand',

Topic Closed

This topic has been closed to new replies.

About this Topic