Home › Forums › General Issues › Get a random item from a relationship field › Reply To: Get a random item from a relationship field
Hi @Matteo Balocco
Your above code shows some mixed directions and doesn’t make too much sense looking at it.
The best thing you can do is simplify the task into steps.
Firstly, just get a random $post from the $posts array. Please read the above link I posted to find out how to do this.
Once you have the random $post, you can then echo it’s title like this:
echo get_the_title($post->ID)
Just test your code line by line. Print out vars and debug the data.
Good luck
Thanks
E
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.