Support

Account

Home Forums Front-end Issues Get relationship fields and display only 1 randomized with it's fields

Unread

Get relationship fields and display only 1 randomized with it's fields

  • I’d like to take all the items from a relationship field and randomly display only one (with it’s associated fields).

    For example, I have a field group titled Featured Team Member, with fields such as team member name, image, position, etc.

    I’d like to be able to select a list of Team Members, and then each time the page loads have one of them display.

    I’ve been able to get the entire list to display, but not been able to use the random query.

    I’ve seen code like below, but am not sure how to make it work:

    $post_object = get_posts(array(
    ‘orderby’ => ‘rand’,
    ‘posts_per_page’ => ‘1’
    ));

    Any help would be great, thanks!

Viewing 1 post (of 1 total)

The topic ‘Get relationship fields and display only 1 randomized with it's fields’ is closed to new replies.