I have a custom field that contains a list of comma separated colors.
I want to randomly select one of those colors.
If get_post_meta returns an array I thought I could randomly pick from that array.
If I try to echo $rand_color_value it just gives me the whole array
How can I randomly select one color from the list in the custom field.
$agrs = array(
'post_type' => 'page',
'tag' => 'colors'
$colorLoop = new WP_Query($agrs);
$theColor = get_post_meta($post->ID, 'colors', false);
$rand_color = array_rand($theColor,1);
$rand_color_value = $theWeight[$rand_color];
<?php endwhile; endif;?>
<?php wp_reset_postdata; ?>
Content will be erased after question is completed.
Enter the email address associated with your account, and we will email you a link to reset your password.
Forgot your password?
These are the countries currently available for verification, with more to come!